Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
32 changes: 32 additions & 0 deletions src/Helper/Service/IdentityFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\View\Helper\Service;

use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\View\Helper\Identity;

class IdentityFactory implements FactoryInterface
{
/**
* {@inheritDoc}
*
* @return \Zend\View\Helper\Identity
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$services = $serviceLocator->getServiceLocator();
$helper = new Identity();
if ($services->has('Zend\Authentication\AuthenticationService')) {
$helper->setAuthenticationService($services->get('Zend\Authentication\AuthenticationService'));
}
return $helper;
}
}
13 changes: 2 additions & 11 deletions src/HelperPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class HelperPluginManager extends AbstractPluginManager
* @var array
*/
protected $factories = array(
'flashmessenger' => 'Zend\View\Helper\Service\FlashMessengerFactory',
'flashmessenger' => 'Zend\View\Helper\Service\FlashMessengerFactory',
'identity' => 'Zend\View\Helper\Service\IdentityFactory',
);

/**
Expand Down Expand Up @@ -92,16 +93,6 @@ public function __construct(ConfigInterface $configuration = null)
{
parent::__construct($configuration);

$this->setFactory('identity', function ($helpers) {
$services = $helpers->getServiceLocator();
$helper = new Helper\Identity();
if (!$services->has('Zend\Authentication\AuthenticationService')) {
return $helper;
}
$helper->setAuthenticationService($services->get('Zend\Authentication\AuthenticationService'));
return $helper;
});

$this->addInitializer(array($this, 'injectRenderer'))
->addInitializer(array($this, 'injectTranslator'));
}
Expand Down

0 comments on commit d42185d

Please sign in to comment.