77[ ![ Coverage Status] [ ico-coveralls ]] [ link-coveralls ]
88
99Presentation layer for Hawkbit PSR-7 Micro PHP framework.
10- Hawkbit Persitence uses factories of ` dasprid/container-interop-doctrine ` and wraps them with in a PresentationService
10+ Hawkbit Presentation uses [ ` league/plates ` ] ( http://platesphp.com/ ) as view engine and wraps it with in a PresentationService
1111
1212## Install
1313
@@ -70,23 +70,13 @@ $app->register(new PresentationServiceProvider([
7070]));
7171```
7272
73- ### Full configuration
74-
75- A full configuration is available on [ DASPRiD/container-interop-doctrine/example/full-config.php] ( https://github.com/DASPRiD/container-interop-doctrine/blob/master/example/full-config.php ) .
76- Refer to [ container-interop-doctrine Documentation] ( https://github.com/DASPRiD/container-interop-doctrine ) for further instructions on factories.
77-
7873### Presentation from Hawbit Application
7974
8075``` php
8176<?php
8277
83- /** @var \Hawkbit\Presentation\PresentationServiceInterface $Presentation */
84- $Presentation = $app[\Hawkbit\Presentation\PresentationServiceInterface::class];
85-
86- $em = $Presentation->getEntityManager();
87-
88- // or with from specific connection
89- $em = $Presentation->getEntityManager('connectionname');
78+ /** @var \Hawkbit\Presentation\PresentationService $Presentation */
79+ $service = $app[\Hawkbit\Presentation\PresentationService::class];
9080
9181```
9282
@@ -97,28 +87,58 @@ Access Presentation service in controller. Hawbit is inject classes to controlle
9787``` php
9888<?php
9989
100- use \Hawkbit\Presentation\PresentationServiceInterface;
90+ use \Hawkbit\Presentation\PresentationService;
91+ use Psr\Http\Message\ServerRequestInterface;
92+ use Psr\Http\Message\ResponseInterface;
10193
102- class MyController{
103-
94+ class MyController
95+ {
10496 /**
105- * @var \Hawkbit\Presentation\PresentationServiceInterface
97+ * @var PresentationService
10698 */
107- private $Presentation = null;
108-
109- public function __construct(PresentationServiceInterface $Presentation){
110- $this->Presentation = $Presentation;
99+ private $presentationService;
100+
101+ /**
102+ * TestInjectableController constructor.
103+ * @param PresentationService $presentation
104+ */
105+ public function __construct(PresentationService $presentation)
106+ {
107+ $this->presentationService = $presentation;
111108 }
112-
113- public function index(){
114- $em = $this->Presentation->getEntityManager();
115-
116- // or with from specific connection
117- $em = $this->Presentation->getEntityManager('connectionname');
109+
110+ public function getIndex(ServerRequestInterface $request, ResponseInterface $response, array $args = [])
111+ {
112+ $response->getBody()->write($this->presentationService->render('index', ['world' => 'World']));
113+ return $response;
118114 }
119115}
120116```
121117
118+ ### Access and extend engine
119+
120+ In most cases you would like to extend or access plates. We recommend to extend plates
121+ in a central point of your application like bootstrap or even better in your project service provider.
122+
123+ ``` php
124+ <?php
125+
126+ use Hawkbit\Presentation\PresentationService;
127+
128+ /** @var PresentationService $service */
129+ $service = $app->getContainer()->get(PresentationService::class);
130+ $service->getEngine()
131+ ->addFolder('acme', __DIR__ . '/templates/acme')
132+ ->registerFunction('uppercase', function ($string) {
133+ return strtoupper($string);
134+ });
135+
136+ ```
137+
138+ ### Plates
139+
140+ Please refer to [ plates documentation] ( http://platesphp.com ) for more details.
141+
122142## Change log
123143
124144Please see [ CHANGELOG] ( CHANGELOG.md ) for more information what has changed recently.
@@ -140,6 +160,7 @@ If you discover any security related issues, please email <mjls@web.de> instead
140160## Credits
141161
142162- [ Marco Bunge] ( https://github.com/mbunge )
163+ - [ Jonathan Reinik (Plates)] ( https://github.com/reinink )
143164- [ All contributors] ( https://github.com/hawkbit/Presentation/graphs/contributors )
144165
145166## License
0 commit comments