Author: Aeneas Rekkas
Inheritance: extends Zend\ServiceManager\AbstractPluginManager
 /**
  * {@inheritDoc}
  * @return AssertionPluginManager
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('Config')['zfc_rbac']['assertion_manager'];
     $pluginManager = new AssertionPluginManager(new Config($config));
     $pluginManager->setServiceLocator($serviceLocator);
     return $pluginManager;
 }
Ejemplo n.º 2
0
 /**
  * @param  string|callable|AssertionInterface $assertion
  * @param  mixed                              $context
  * @return bool
  * @throws Exception\InvalidArgumentException If an invalid assertion is passed
  */
 protected function assert($assertion, $context = null)
 {
     if (is_callable($assertion)) {
         return $assertion($this, $context);
     } elseif ($assertion instanceof AssertionInterface) {
         return $assertion->assert($this, $context);
     } elseif (is_string($assertion)) {
         $assertion = $this->assertionPluginManager->get($assertion);
         return $assertion->assert($this, $context);
     }
     throw new Exception\InvalidArgumentException(sprintf('Assertion must be callable, string or implement ZfcRbac\\Assertion\\AssertionInterface, "%s" given', is_object($assertion) ? get_class($assertion) : gettype($assertion)));
 }