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

Commit

Permalink
Merge 9816748 into 8ca97c9
Browse files Browse the repository at this point in the history
  • Loading branch information
Ocramius committed Jul 3, 2016
2 parents 8ca97c9 + 9816748 commit 2496515
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 90 deletions.
21 changes: 15 additions & 6 deletions .travis.yml
Expand Up @@ -3,15 +3,24 @@ sudo: false
language: php

php:
- 5.3.3
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- nightly
- hhvm

env:
matrix:
- DEPENDENCIES=""
- DEPENDENCIES="--prefer-lowest --prefer-stable"

matrix:
allow_failures:
- php: hhvm
- php: nightly

before_script:
- composer update --prefer-source
- composer self-update
- composer update $DEPENDENCIES

script:
- ./vendor/bin/phpunit
Expand Down
23 changes: 13 additions & 10 deletions composer.json
Expand Up @@ -13,17 +13,20 @@
],
"minimum-stability": "dev",
"require": {
"zendframework/zend-mvc": "~2.2",
"zendframework/zend-servicemanager": "~2.2",
"zendframework/zend-modulemanager": "~2.2",
"zendframework/zend-http": "~2.2",
"ocramius/proxy-manager": "1.0.*"
"php": "^7.0.0",
"container-interop/container-interop": "^1.1.0",
"zendframework/zend-mvc": "^3.0.2",
"zendframework/zend-eventmanager": "^3.0.1",
"zendframework/zend-servicemanager": "^3.1.0",
"zendframework/zend-modulemanager": "^2.7.2",
"zendframework/zend-http": "^2.5.4",
"ocramius/proxy-manager": "^2.0.3"
},
"require-dev": {
"zendframework/zendframework": "~2.2",
"zendframework/zend-developer-tools": "0.*",
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "2.0.*@ALPHA"
"zendframework/zendframework": "^3.0.0",
"zendframework/zend-developer-tools": "^1.1.0",
"phpunit/phpunit": "5.3.*",
"squizlabs/php_codesniffer": "^2.6.1"
},
"suggest": {
"zendframework/zend-developer-tools": "Allows displaying service dependencies"
Expand All @@ -40,7 +43,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.2-dev"
"dev-master": "3.1-dev"
}
}
}
Expand Up @@ -18,9 +18,10 @@

namespace OcraServiceManager\DelegatorFactory;

use Interop\Container\ContainerInterface;
use ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory;
use Zend\ServiceManager\DelegatorFactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use ProxyManager\Proxy\AccessInterceptorInterface;
use Zend\ServiceManager\Factory\DelegatorFactoryInterface;

/**
* Factory responsible of building
Expand Down Expand Up @@ -56,16 +57,18 @@ public function __construct(AccessInterceptorScopeLocalizerFactory $proxyFactory

/**
* {@inheritDoc}
*
* @return AccessInterceptorInterface|ContainerInterface
*/
public function createDelegatorWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName, $callback)
public function __invoke(ContainerInterface $container, $name, callable $callback, array $options = null)
{
$service = call_user_func($callback);

if (! $service instanceof ServiceLocatorInterface) {
if (! $service instanceof ContainerInterface) {
return $service;
}

// @todo maybe this should be a callback, and `locatorInterceptors` should not be used explicitly
return $this->proxyFactory->createProxy($service, array(), $this->locatorInterceptors);
return $this->proxyFactory->createProxy($service, [], $this->locatorInterceptors);
}
}
Expand Up @@ -21,8 +21,6 @@
use ProxyManager\Configuration;
use ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory;
use ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

/**
* Factory responsible of building
Expand All @@ -34,14 +32,14 @@
* @author Marco Pivetta <ocramius@gmail.com>
* @license MIT
*/
class AccessInterceptorProxyFactoryFactory implements FactoryInterface
class AccessInterceptorProxyFactoryFactory
{
/**
* {@inheritDoc}
*
* @return AccessInterceptorScopeLocalizerFactory
*/
public function createService(ServiceLocatorInterface $serviceLocator)
public function __invoke()
{
$config = new Configuration();

Expand Down
13 changes: 6 additions & 7 deletions src/OcraServiceManager/ServiceFactory/ApplicationFactory.php
Expand Up @@ -18,32 +18,31 @@

namespace OcraServiceManager\ServiceFactory;

use Interop\Container\ContainerInterface;
use Zend\Mvc\Application;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

/**
* Factory responsible of building an application with the overloaded ServiceManager
*
* @author Marco Pivetta <ocramius@gmail.com>
* @license MIT
*/
class ApplicationFactory implements FactoryInterface
class ApplicationFactory
{
/**
* Create the Application service
*
* Creates a Zend\Mvc\Application service, passing it the configuration
* service and the overloaded service manager instance.
*
* @param ServiceLocatorInterface $serviceLocator
* @param ContainerInterface $container
* @return Application
*/
public function createService(ServiceLocatorInterface $serviceLocator)
public function __invoke(ContainerInterface $container)
{
return new Application(
$serviceLocator->get('Config'),
$serviceLocator->get('OcraServiceManager\\ServiceManager')
$container->get('Config'),
$container->get('OcraServiceManager\\ServiceManager')
);
}
}
16 changes: 9 additions & 7 deletions src/OcraServiceManager/ServiceFactory/EventManagerFactory.php
Expand Up @@ -18,9 +18,9 @@

namespace OcraServiceManager\ServiceFactory;

use Interop\Container\ContainerInterface;
use Zend\EventManager\EventManager;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\EventManager\EventManagerInterface;

/**
* Factory responsible of building an {@see \Zend\EventManager\EventManagerInterface}
Expand All @@ -29,18 +29,20 @@
* @author Marco Pivetta <ocramius@gmail.com>
* @license MIT
*/
class EventManagerFactory implements FactoryInterface
class EventManagerFactory
{
/**
* {@inheritDoc}
* @param ContainerInterface $container
*
* @return EventManagerInterface
*/
public function createService(ServiceLocatorInterface $serviceLocator)
public function __invoke(ContainerInterface $container)
{
/* @var $logger \OcraServiceManager\ServiceManager\Logger */
$logger = $serviceLocator->get('OcraServiceManager\\ServiceManager\\Logger');
$logger = $container->get('OcraServiceManager\\ServiceManager\\Logger');
$eventManager = new EventManager();

$eventManager->attach($logger);
$logger->attach($logger);

return $eventManager;
}
Expand Down
Expand Up @@ -18,23 +18,22 @@

namespace OcraServiceManager\ServiceFactory;

use Interop\Container\ContainerInterface;
use OcraServiceManager\DelegatorFactory\ServiceLocatorDelegatorFactory;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

class ServiceLocatorDelegatorFactoryFactory implements FactoryInterface
class ServiceLocatorDelegatorFactoryFactory
{
/**
* {@inheritDoc}
* @param ContainerInterface $container
*
* @return ServiceLocatorDelegatorFactory
*/
public function createService(ServiceLocatorInterface $serviceLocator)
public function __invoke(ContainerInterface $container)
{
/* @var $proxyFactory \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory */
$proxyFactory = $serviceLocator->get('OcraServiceManager\\ServiceManager\\AccessInterceptorProxyFactory');
$proxyFactory = $container->get('OcraServiceManager\\ServiceManager\\AccessInterceptorProxyFactory');
/* @var $locatorInterceptors \Closure[] */
$locatorInterceptors = $serviceLocator->get('OcraServiceManager\\ServiceManager\\AccessInterceptors');
$locatorInterceptors = $container->get('OcraServiceManager\\ServiceManager\\AccessInterceptors');

return new ServiceLocatorDelegatorFactory($proxyFactory, $locatorInterceptors);
}
Expand Down
Expand Up @@ -18,10 +18,9 @@

namespace OcraServiceManager\ServiceFactory;

use Interop\Container\ContainerInterface;
use OcraServiceManager\ServiceManager\Event\ServiceManagerEvent;
use Zend\EventManager\EventManagerInterface;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

/**
* Factory responsible of instantiating an array of pre- and post-
Expand All @@ -31,19 +30,17 @@
* @author Marco Pivetta <ocramius@gmail.com>
* @license MIT
*/
class ServiceManagerAccessInterceptorsFactory implements FactoryInterface
class ServiceManagerAccessInterceptorsFactory
{
/**
* Create service
*
* @param ServiceLocatorInterface $serviceLocator
* @param ContainerInterface $container
*
* @return \Closure[]
*/
public function createService(ServiceLocatorInterface $serviceLocator)
public function __invoke(ContainerInterface $container)
{
/* @var $eventManager \Zend\EventManager\EventManagerInterface */
$eventManager = $serviceLocator->get('OcraServiceManager\\ServiceManager\\EventManager');
$eventManager = $container->get('OcraServiceManager\\ServiceManager\\EventManager');
$creationListener = $this->createInstantiationListener($eventManager);

return array(
Expand Down
30 changes: 15 additions & 15 deletions src/OcraServiceManager/ServiceFactory/ServiceManagerFactory.php
Expand Up @@ -18,7 +18,7 @@

namespace OcraServiceManager\ServiceFactory;

use Zend\ServiceManager\FactoryInterface;
use Interop\Container\ContainerInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\ServiceManager\ServiceManager;

Expand All @@ -28,41 +28,41 @@
* @author Marco Pivetta <ocramius@gmail.com>
* @license MIT
*/
class ServiceManagerFactory implements FactoryInterface
class ServiceManagerFactory
{
/**
* Create an overloaded service manager
*
* @param ServiceLocatorInterface $serviceLocator
* @param string|null $name
* @param ServiceLocatorInterface $container
*
* @return ServiceLocatorInterface
*/
public function createService(ServiceLocatorInterface $serviceLocator, $name = null)
public function createService(ContainerInterface $container)
{
$config = $serviceLocator->get('Config');
$config = $container->get('Config');

if (! $config['ocra_service_manager']['logged_service_manager']) {
return $serviceLocator;
return $container;
}

/* @var $proxyFactory \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory */
$proxyFactory = $serviceLocator->get('OcraServiceManager\\ServiceManager\\AccessInterceptorProxyFactory');
$proxyFactory = $container->get('OcraServiceManager\\ServiceManager\\AccessInterceptorProxyFactory');
/* @var $locatorInterceptors \Closure[] */
$locatorInterceptors = $serviceLocator->get('OcraServiceManager\\ServiceManager\\AccessInterceptors');
$locatorInterceptors = $container->get('OcraServiceManager\\ServiceManager\\AccessInterceptors');

// @todo maybe this should be a callback, and `locatorInterceptors` should not be used explicitly
$proxyLocator = $proxyFactory->createProxy($serviceLocator, array(), $locatorInterceptors);
$proxyLocator = $proxyFactory->createProxy($container, array(), $locatorInterceptors);

if (! ($name && $serviceLocator instanceof ServiceManager)) {
if (! $container instanceof ServiceManager) {
return $proxyLocator;
}

// @todo this service hardcoding should be removed
$allowOverrides = $serviceLocator->getAllowOverride();
$allowOverrides = $container->getAllowOverride();

$serviceLocator->setAllowOverride(true);
$serviceLocator->setService('ServiceManager', $proxyLocator);
$serviceLocator->setAllowOverride($allowOverrides);
$container->setAllowOverride(true);
$container->setService('ServiceManager', $proxyLocator);
$container->setAllowOverride($allowOverrides);

return $proxyLocator;
}
Expand Down
8 changes: 3 additions & 5 deletions src/OcraServiceManager/ServiceFactory/YumlUrlFactory.php
Expand Up @@ -20,21 +20,19 @@

use OcraServiceManager\View\Helper\YumlUrl;
use Zend\Escaper\Escaper;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

/**
* Factory responsible of building a {@see \OcraServiceManager\View\Helper\YumlUrl}
*
* @author Marco Pivetta <ocramius@gmail.com>
* @license MIT
*/
class YumlUrlFactory implements FactoryInterface
class YumlUrlFactory
{
/**
* {@inheritDoc}
* @return YumlUrl
*/
public function createService(ServiceLocatorInterface $serviceLocator)
public function __invoke()
{
return new YumlUrl(new Escaper());
}
Expand Down
12 changes: 4 additions & 8 deletions src/OcraServiceManager/ServiceFactory/ZDTCollectorFactory.php
Expand Up @@ -18,25 +18,21 @@

namespace OcraServiceManager\ServiceFactory;

use Interop\Container\ContainerInterface;
use OcraServiceManager\ServiceManager\ZDTCollector;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

/**
* Factory responsible of building a {@see \OcraServiceManager\ServiceManager\ZDTCollector}
*
* @author Marco Pivetta <ocramius@gmail.com>
* @license MIT
*/
class ZDTCollectorFactory implements FactoryInterface
class ZDTCollectorFactory
{
/**
* {@inheritDoc}
*/
public function createService(ServiceLocatorInterface $serviceLocator)
public function __invoke(ContainerInterface $container)
{
/* @var $logger \OcraServiceManager\ServiceManager\Logger */
$logger = $serviceLocator->get('OcraServiceManager\\ServiceManager\\Logger');
$logger = $container->get('OcraServiceManager\\ServiceManager\\Logger');

return new ZDTCollector($logger);
}
Expand Down

0 comments on commit 2496515

Please sign in to comment.