File tree Expand file tree Collapse file tree 4 files changed +73
-0
lines changed Expand file tree Collapse file tree 4 files changed +73
-0
lines changed Original file line number Diff line number Diff line change 2
2
composer.lock
3
3
vendor /
4
4
.subsplit
5
+ .puli
Original file line number Diff line number Diff line change @@ -209,6 +209,22 @@ This is the same lookup that is `done in Symfony <http://symfony.com/doc/current
209
209
// $app is an application
210
210
$app->get('_error/{$statusCode}', new ErrorPageController($app['exception_controller']));
211
211
212
+ Puli
213
+ ~~~~
214
+
215
+ Brick comes with experimental support for Puli, which helps manage resources in composer packages.
216
+
217
+ .. code-block :: php
218
+
219
+ <?php
220
+
221
+ use Brick\Provider\PuliServiceProvider;
222
+
223
+ (new PuliServiceProvider)->register($app);
224
+
225
+ If a ``twig `` service exists it will register ``PuliTemplateLoader `` and its extension if ``puli/url-generator ``
226
+ package is present.
227
+
212
228
All in One
213
229
~~~~~~~~~~
214
230
Original file line number Diff line number Diff line change
1
+ {
2
+ "version" : " 1.0" ,
3
+ "name" : " flint/brick" ,
4
+ "packages" : {
5
+ }
6
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Brick \Provider ;
4
+
5
+ use Pimple \Container ;
6
+ use Puli \TwigExtension \PuliExtension ;
7
+ use Puli \TwigExtension \PuliTemplateLoader ;
8
+
9
+ class PuliServiceProvider implements \Pimple \ServiceProviderInterface
10
+ {
11
+ /**
12
+ * {@inheritdoc}
13
+ */
14
+ public function register (Container $ app )
15
+ {
16
+ $ app ['puli.factory ' ] = function () {
17
+ $ factoryClass = PULI_FACTORY_CLASS ;
18
+
19
+ return new $ factoryClass ();
20
+ };
21
+
22
+ $ app ['puli.repository ' ] = function ($ app ) {
23
+ return $ app ['puli.factory ' ]->createRepository ();
24
+ };
25
+
26
+ $ app ['puli.discovery ' ] = function ($ app ) {
27
+ return $ app ['puli.factory ' ]->createDiscovery ();
28
+ };
29
+
30
+ $ app ['puli.url_generator ' ] = function ($ app ) {
31
+ return $ app ['puli.factory ' ]->createUrlGenerator ($ app ['puli.discovery ' ]);
32
+ };
33
+
34
+ if (isset ($ app ['twig ' ])) {
35
+ if (interface_exists ('Puli\UrlGenerator\Api\UrlGenerator ' )) {
36
+ $ app ->extend ('twig ' , function ($ twig , $ app ) {
37
+ $ twig ->addExtension (new PuliExtension ($ app ['puli.repository ' ], $ app ['puli.url_generator ' ]));
38
+
39
+ return $ twig ;
40
+ });
41
+ }
42
+
43
+ $ app ->extend ('twig.loader ' , function ($ loader , $ app ) {
44
+ $ loader ->addLoader (new PuliTemplateLoader ($ app ['puli.repository ' ]));
45
+
46
+ return $ loader ;
47
+ });
48
+ }
49
+ }
50
+ }
You can’t perform that action at this time.
0 commit comments