Spork Code Libraries

ViewModelIdentity

Injects a child view model into the layout to display authentication / identity info.

The view model renders the template layout/identity and makes it available in the layout template as the property 'identity'.

layout/layout.phtml ...

...

The listener retrives an authentication service and identity model from the service manager and makes them available in the identity template as the properties 'auth' and 'identity'

layout/identity.phtml <?php if ($this->auth->hasIdentity()): ?>

<?php echo $this->identity->name; ?>

<?php else: ?>

<a href="/login">Log In</a>

<?php endif: ?>

Summary

Properties

Constants

Extends
\Zend\EventManager\AbstractListenerAggregate

Methods

attach()

attach(\Zend\EventManager\EventManagerInterface  $events, \Spork\Mvc\Listener\number  $priority = 1) 

Attach listeners

Parameters

\Zend\EventManager\EventManagerInterface $events
\Spork\Mvc\Listener\number $priority
See also

injectIdentityModel()

injectIdentityModel(\Zend\Mvc\MvcEvent  $event) 

Inject identity view model into layout

Parameters

\Zend\Mvc\MvcEvent $event

Throws

\Exception