This repository has been archived by the owner on Jul 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #335 from prolic/zf3
allow zf3
- Loading branch information
Showing
68 changed files
with
913 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,8 @@ | |
|
||
namespace ZfcRbac\Factory; | ||
|
||
use Interop\Container\ContainerInterface; | ||
use Zend\ServiceManager\FactoryInterface; | ||
use Zend\ServiceManager\MutableCreationOptionsInterface; | ||
use Zend\ServiceManager\ServiceLocatorInterface; | ||
use ZfcRbac\Guard\ControllerGuard; | ||
|
||
|
@@ -29,13 +29,21 @@ | |
* @author Michaël Gallego <[email protected]> | ||
* @license MIT | ||
*/ | ||
class ControllerGuardFactory implements FactoryInterface, MutableCreationOptionsInterface | ||
class ControllerGuardFactory implements FactoryInterface | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
protected $options = []; | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function __construct(array $options = []) | ||
{ | ||
$this->setCreationOptions($options); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
|
@@ -45,22 +53,36 @@ public function setCreationOptions(array $options) | |
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* @param ContainerInterface $container | ||
* @param string $requestedName | ||
* @param array|null $options | ||
* @return ControllerGuard | ||
*/ | ||
public function createService(ServiceLocatorInterface $serviceLocator) | ||
public function __invoke(ContainerInterface $container, $requestedName, array $options = null) | ||
{ | ||
$parentLocator = $serviceLocator->getServiceLocator(); | ||
if (null === $options) { | ||
$options = []; | ||
} | ||
|
||
/* @var \ZfcRbac\Options\ModuleOptions $moduleOptions */ | ||
$moduleOptions = $parentLocator->get('ZfcRbac\Options\ModuleOptions'); | ||
$moduleOptions = $container->get('ZfcRbac\Options\ModuleOptions'); | ||
|
||
/* @var \ZfcRbac\Service\RoleService $roleService */ | ||
$roleService = $parentLocator->get('ZfcRbac\Service\RoleService'); | ||
$roleService = $container->get('ZfcRbac\Service\RoleService'); | ||
|
||
$controllerGuard = new ControllerGuard($roleService, $this->options); | ||
$controllerGuard = new ControllerGuard($roleService, $options); | ||
$controllerGuard->setProtectionPolicy($moduleOptions->getProtectionPolicy()); | ||
|
||
return $controllerGuard; | ||
} | ||
|
||
|
||
/** | ||
* {@inheritDoc} | ||
* @return ControllerGuard | ||
*/ | ||
public function createService(ServiceLocatorInterface $serviceLocator) | ||
{ | ||
return $this($serviceLocator->getServiceLocator(), ControllerGuard::class, $this->options); | ||
} | ||
} |
Oops, something went wrong.