Commit 29c7a70e authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Modufucations pour passer à ZF3.

parent aa4d1942
Loading
Loading
Loading
Loading
+8 −6
Changes for src/BjyAuthorize/Guard/AbstractGuard.php: 8 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -48,20 +48,22 @@ abstract class AbstractGuard extends AbstractListenerAggregate implements
    }

    /**
     * @return mixed
     * @return void
     */
    public function processConfig()
    {
        $this->makeRules($this->config);
        $this->makeRules();
    }

    /**
     * @param array $rules
     *
     */
    protected function makeRules(array $rules)
    protected function makeRules()
    {
        $rules = $this->config;

        foreach ($rules as $rule) {
            $rule['roles']  = (array) $rule['roles'];
            $rule['roles']  = (array) ($rule['roles'] ?? null);
            $rule['action'] = isset($rule['action']) ? (array) $rule['action'] : array(null);

            foreach ($this->extractResourcesFromRule($rule) as $resource) {
@@ -98,7 +100,7 @@ abstract class AbstractGuard extends AbstractListenerAggregate implements
        $rules = array();
        foreach ($this->rules as $resource => $ruleData) {
            $rule   = array();
            $rule[] = $ruleData['roles'];
            $rule[] = (array) ($ruleData['roles'] ?? null);
            $rule[] = $resource;

            if (isset($ruleData['assertion'])) {
+5 −7
Changes for src/BjyAuthorize/Module.php: 5 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace BjyAuthorize;

use Interop\Container\ContainerInterface;
use Zend\EventManager\AbstractListenerAggregate;
use Zend\EventManager\EventInterface;
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
@@ -9,7 +10,6 @@ use Zend\ModuleManager\Feature\BootstrapListenerInterface;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
use Zend\ModuleManager\Feature\ControllerPluginProviderInterface;
use Zend\ModuleManager\Feature\ViewHelperProviderInterface;
use Zend\ServiceManager\AbstractPluginManager;

/**
 * BjyAuthorize Module
@@ -52,10 +52,9 @@ class Module implements
    {
        return array(
            'factories' => array(
                'isAllowed' => function (AbstractPluginManager $pluginManager) {
                    $serviceLocator = $pluginManager;
                'isAllowed' => function (ContainerInterface $container) {
                    /* @var $authorize \BjyAuthorize\Service\Authorize */
                    $authorize = $serviceLocator->get('BjyAuthorize\Service\Authorize');
                    $authorize = $container->get('BjyAuthorize\Service\Authorize');

                    return new View\Helper\IsAllowed($authorize);
                }
@@ -70,10 +69,9 @@ class Module implements
    {
        return array(
            'factories' => array(
                'isAllowed' => function (AbstractPluginManager $pluginManager) {
                    $serviceLocator = $pluginManager;
                'isAllowed' => function (ContainerInterface $container) {
                    /* @var $authorize \BjyAuthorize\Service\Authorize */
                    $authorize = $serviceLocator->get('BjyAuthorize\Service\Authorize');
                    $authorize = $container->get('BjyAuthorize\Service\Authorize');

                    return new Controller\Plugin\IsAllowed($authorize);
                }
+2 −1
Changes for src/BjyAuthorize/Service/BaseProvidersServiceFactory.php: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -32,7 +32,8 @@ abstract class BaseProvidersServiceFactory implements FactoryInterface
        foreach ($config[static::PROVIDER_SETTING] as $providerName => $providerConfig) {
            if ($container->has($providerName)) {
                $provider = $container->get($providerName);
                if ($provider instanceof ProviderInterface) {
                if (method_exists($provider, 'setConfig')) {
//                if ($provider instanceof ProviderInterface) {
                    $provider->setConfig($providerConfig);
                    $provider->processConfig();
                }