Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Move Identity closure to separate factory #4155

Closed
wants to merge 5 commits into
from

Conversation

Projects
None yet
4 participants
Contributor

maxnuf commented Mar 31, 2013

  • Move Identity Controller Plugin to factory
  • Move Identity View Helper to factory
Move Identity closure to separate factory
*   Move Identity Controller Plugin to factory
*   Move Identity View Helper to factory

@iquabius iquabius commented on an outdated diff Mar 31, 2013

library/Zend/Mvc/Controller/PluginManager.php
@@ -23,6 +23,15 @@
class PluginManager extends AbstractPluginManager
{
+ /**
+ * Default set of plugins factories
+ *
+ * @var array
+ */
+ protected $factories = array(
+ 'identity' => 'Zend\Mvc\Controller\Plugin\Service\IdentityFactory',
@iquabius

iquabius Mar 31, 2013

Contributor

You can leave just one space here, just align when in the same array.

@iquabius iquabius and 1 other commented on an outdated diff Mar 31, 2013

library/Zend/Mvc/Controller/PluginManager.php
@@ -65,17 +74,6 @@ class PluginManager extends AbstractPluginManager
public function __construct(ConfigInterface $configuration = null)
{
parent::__construct($configuration);
-
@iquabius

iquabius Mar 31, 2013

Contributor

I'm not sure but I think you can remove the entire __contruct() method here, since it is just calling the parent constructor. Can someone confirm this is right?

@maxnuf

maxnuf Mar 31, 2013

Contributor

I wasn't sure either, but I removed it now

@Ocramius Ocramius commented on an outdated diff Mar 31, 2013

...end/Mvc/Controller/Plugin/Service/IdentityFactory.php
+namespace Zend\Mvc\Controller\Plugin\Service;
+
+use Zend\ServiceManager\FactoryInterface;
+use Zend\ServiceManager\ServiceLocatorInterface;
+use Zend\Mvc\Controller\Plugin\Identity;
+
+class IdentityFactory implements FactoryInterface
+{
+ public function createService(ServiceLocatorInterface $serviceLocator)
+ {
+ $services = $serviceLocator->getServiceLocator();
+ $helper = new Identity();
+ if (!$services->has('Zend\Authentication\AuthenticationService')) {
+ return $helper;
+ }
+ $helper->setAuthenticationService($services->get('Zend\Authentication\AuthenticationService'));
@Ocramius

Ocramius Mar 31, 2013

Member

You can simplify it

if ($services->has('Zend\Authentication\AuthenticationService')) {
    $helper->setAuthenticationService($services->get('Zend\Authentication\AuthenticationService'));
}

@Ocramius Ocramius commented on an outdated diff Mar 31, 2013

library/Zend/View/Helper/Service/IdentityFactory.php
+namespace Zend\View\Helper\Service;
+
+use Zend\ServiceManager\FactoryInterface;
+use Zend\ServiceManager\ServiceLocatorInterface;
+use Zend\View\Helper\Identity;
+
+class IdentityFactory implements FactoryInterface
+{
+ public function createService(ServiceLocatorInterface $serviceLocator)
+ {
+ $services = $serviceLocator->getServiceLocator();
+ $helper = new Identity();
+ if (!$services->has('Zend\Authentication\AuthenticationService')) {
+ return $helper;
+ }
+ $helper->setAuthenticationService($services->get('Zend\Authentication\AuthenticationService'));
@Ocramius

Ocramius Mar 31, 2013

Member

You can simplify it

if ($services->has('Zend\Authentication\AuthenticationService')) {
    $helper->setAuthenticationService($services->get('Zend\Authentication\AuthenticationService'));
}

@Ocramius Ocramius commented on an outdated diff Mar 31, 2013

...end/Mvc/Controller/Plugin/Service/IdentityFactory.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\Mvc\Controller\Plugin\Service;
+
+use Zend\ServiceManager\FactoryInterface;
+use Zend\ServiceManager\ServiceLocatorInterface;
+use Zend\Mvc\Controller\Plugin\Identity;
+
+class IdentityFactory implements FactoryInterface
+{
+ public function createService(ServiceLocatorInterface $serviceLocator)
@Ocramius

Ocramius Mar 31, 2013

Member

Missing docblock with {@inheritDoc} and proper return type

@Ocramius Ocramius commented on an outdated diff Mar 31, 2013

library/Zend/View/Helper/Service/IdentityFactory.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
+{
+ public function createService(ServiceLocatorInterface $serviceLocator)
@Ocramius

Ocramius Mar 31, 2013

Member

Missing docblock with {@inheritDoc} and proper return type

@ghost ghost assigned weierophinney Apr 12, 2013

weierophinney added a commit that referenced this pull request Apr 12, 2013

Merge pull request #4155 from maxnuf/feature/refactor-identity-helper
Move Identity closure to separate factory

weierophinney added a commit that referenced this pull request Apr 12, 2013

Owner

weierophinney commented Apr 12, 2013

Since this introduces a new class (the factory), I've merged it against develop for release with 2.2.0.

Thanks -- this will make it far easier to override what service is used for the helper/plugin!

weierophinney added a commit to zendframework/zend-view that referenced this pull request May 15, 2015

Merge pull request zendframework/zendframework#4155 from maxnuf/featu…
…re/refactor-identity-helper

Move Identity closure to separate factory

weierophinney added a commit to zendframework/zend-view that referenced this pull request May 15, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment