You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> We're currently in a process moving all services into the Utils namespace and make them all accessible from a new Utils service.
42
+
This is a backport and essential feature of the `v3` branch. We recommend to refactor your code to use the `Utils`-service locator, and to only use this pattern in new code.
34
43
35
-
This Bundle is a collection of utils to solve recurring tasks. See the [API Documentation](https://heimrichhannot.github.io/contao-utils-bundle/) to see all util-classes and -methods.
44
+
> [!NOTE]
45
+
> We're currently in a process to move all services into the Utils namespace and make them all accessible from the new Utils service.
36
46
37
-
The default way to access the util methods is the `Utils`-service (currently not all services are available there yet). The utils service is best used with dependency injection, but is also available from the service container as public service for usage in legacy code.
47
+
This Bundle is a collection of utils to solve recurring tasks. See the [API Documentation](https://heimrichhannot.github.io/contao-utils-bundle/) for all util classes and methods.
38
48
39
-
```php
40
-
use HeimrichHannot\UtilsBundle\Util\Utils;
41
-
42
-
class MyClass{
43
-
/** @var Utils */
44
-
protected $utils;
45
-
46
-
public function __construct(Utils $utils) {
47
-
$this->utils = $utils;
48
-
}
49
-
50
-
public function someActions(): bool {
51
-
return $this->utils->string()->startsWith('Lorem ipsum dolor sit amet', 'Lorem');
52
-
}
53
-
}
54
-
```
49
+
The "default" way to access utils is the `Utils`-service
50
+
51
+
> [!NOTE]
52
+
> Currently, not all services have been backported to the new service locator and are still only available through service tags.
53
+
54
+
The utils service is used best with dependency injection, but is also available from the service container as a public service to be used in legacy code.
55
55
56
-
To access services that are not available through the `Utils`-service, inject or call them directly.
56
+
```php
57
+
use HeimrichHannot\UtilsBundle\Util\Utils;
58
+
59
+
class MyService {
60
+
/** @var Utils */
61
+
protected $utils;
62
+
63
+
public function __construct(Utils $utils) {
64
+
$this->utils = $utils;
65
+
}
66
+
67
+
public function someActions(): bool {
68
+
return $this->utils->string()->startsWith('Lorem ipsum dolor sit amet', 'Lorem');
69
+
}
70
+
}
71
+
```
72
+
73
+
To access services that are not available through the `Utils` service, inject or call them directly.
57
74
58
-
> Keep in mind that all services are about to be moved to the Utils namespace and will be deprecated (and removed in version 3.0) in the future.
75
+
> [!IMPORTANT]
76
+
> Keep in mind that all utils are on the brink of being moved to the `Utils`-service locator and won't be available through service tags in `v3`.
59
77
78
+
### Index of Available Services
60
79
61
-
Available [Service](src/Resources/config/services.yml) (as of version 2.131):
80
+
Available [Services](src/Resources/config/services.yml) (as of version 2.131):
[~~PdfCreator~~](docs/utils/pdf/pdfcreator.md) - ~~High-level API to create pdf files with PHP~~ (PDFCreator was moved into it's[own library](https://github.com/heimrichhannot/pdf-creator))
187
+
~~[PdfCreatorx](docs/utils/pdf/pdfcreator.md) - High-level API to create pdf files with PHP~~ (PDFCreator has moved to its[own library](https://github.com/heimrichhannot/pdf-creator).)
@@ -292,9 +310,9 @@ Use the download extension to render download elements, get download links, down
292
310
293
311
## Insert tags
294
312
295
-
| Insert tag | Description |
296
-
|---|---|
297
-
| {{twig::*}} | This tag will be replaced with the rendered output of a given twig template, that can be sourced in `bundle/src/Resources/views` or contao root `/templates` directory (replace 1st * with template name e.g. `svg_logo_company` and 2nd * with serialized parameters that should be passed to the template) |
| {{twig::*}} | This tag will be replaced with the rendered output of a given twig template, that can be sourced in `bundle/src/Resources/views` or contao root `/templates` directory (replace 1st * with template name e.g. `svg_logo_company` and 2nd * with serialized parameters that should be passed to the template) |
0 commit comments