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

[WIP] V3 readiness #35

Closed
wants to merge 10 commits into from
Closed
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"zendframework/zend-paginator": "~2.5",
"zendframework/zend-permissions-acl": "~2.5",
"zendframework/zend-serializer": "~2.5",
"zendframework/zend-servicemanager": "dev-develop as 2.7.0",
"zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3",
"zendframework/zend-session": "dev-master",
"zendframework/zend-uri": "~2.5",
"fabpot/php-cs-fixer": "1.7.*",
Expand Down
18 changes: 17 additions & 1 deletion src/Helper/Service/FlashMessengerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
namespace Zend\View\Helper\Service;

use Interop\Container\ContainerInterface;
use Zend\ServiceManager\Factory\FactoryInterface;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\View\Helper\FlashMessenger;

class FlashMessengerFactory implements FactoryInterface
Expand All @@ -25,6 +26,10 @@ class FlashMessengerFactory implements FactoryInterface
*/
public function __invoke(ContainerInterface $container, $name, array $options = null)
{
// test if we are using Zend\ServiceManager v2 or v3
if (! method_exists($container, 'configure')) {
$container = $container->getServiceLocator();
}
$helper = new FlashMessenger();
$controllerPluginManager = $container->get('ControllerPluginManager');
$flashMessenger = $controllerPluginManager->get('flashmessenger');
Expand All @@ -47,4 +52,15 @@ public function __invoke(ContainerInterface $container, $name, array $options =

return $helper;
}

/**
* Create service
*
* @param ServiceLocatorInterface $serviceLocator
* @return mixed
*/
public function createService(ServiceLocatorInterface $serviceLocator, $rName = null, $cName = null)
{
return $this($serviceLocator, $cName);
}
}
18 changes: 17 additions & 1 deletion src/Helper/Service/IdentityFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
namespace Zend\View\Helper\Service;

use Interop\Container\ContainerInterface;
use Zend\ServiceManager\Factory\FactoryInterface;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\View\Helper\Identity;

class IdentityFactory implements FactoryInterface
Expand All @@ -25,10 +26,25 @@ class IdentityFactory implements FactoryInterface
*/
public function __invoke(ContainerInterface $container, $name, array $options = null)
{
// test if we are using Zend\ServiceManager v2 or v3
if (! method_exists($container, 'configure')) {
$container = $container->getServiceLocator();
}
$helper = new Identity();
if ($container->has('Zend\Authentication\AuthenticationService')) {
$helper->setAuthenticationService($container->get('Zend\Authentication\AuthenticationService'));
}
return $helper;
}

/**
* Create service
*
* @param ServiceLocatorInterface $serviceLocator
* @return mixed
*/
public function createService(ServiceLocatorInterface $serviceLocator, $rName = null, $cName = null)
{
return $this($serviceLocator, $cName);
}
}
Loading