Slide 58
Slide 58 text
58
Zend Expressive Workshop
●
Lab 04 – Database Connected Middleware (Cont’d)
– Create a User middleware (Cont’d
●
Add a middleware class (Cont’d)
– Add a constructor to receive/set $template and $adapter
●
Typehint $template with Template\TemplateRendererInterface
– Add an invoke method leveraging Server\RequestInterface,
ResponseInterface, and $next as callable.
– Using the Zend Db adapter create the query for Sqlite.
●
For Sqlite this involves defining a statement, then executing
– Return the HtmlResponse rendering the view template.
●
Add a factory class to prepare the items needed by the Action just
created
– Use Interop\Container\ContainerInterface,
Zend\Expressive\Template\TemplateRendererInterface, and
Zend\Db\Adapter\AdapterInterface.