0 follower

Final Class Yiisoft\Rbac\Rules\Container\RulesContainer

InheritanceYiisoft\Rbac\Rules\Container\RulesContainer
ImplementsYiisoft\Rbac\RuleFactoryInterface

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( \Psr\Container\ContainerInterface $container, array $definitions = [], boolean $validate true )
$container \Psr\Container\ContainerInterface
$definitions array
$validate boolean
throws \Yiisoft\Definitions\Exception\InvalidConfigException

                public function __construct(ContainerInterface $container, array $definitions = [], bool $validate = true)
{
    $this->factory = new Factory($container, $definitions, $validate);
}

            
create() public method

public \Yiisoft\Rbac\RuleInterface create ( string $name )
$name string
throws \Yiisoft\Rbac\Exception\RuleInterfaceNotImplementedException
throws \Yiisoft\Rbac\Exception\RuleNotFoundException
throws \Yiisoft\Definitions\Exception\CircularReferenceException
throws \Yiisoft\Definitions\Exception\InvalidConfigException
throws \Yiisoft\Definitions\Exception\NotInstantiableException

                public function create(string $name): RuleInterface
{
    if (!array_key_exists($name, $this->instances)) {
        try {
            $rule = $this->factory->create($name);
        } catch (NotFoundException $e) {
            throw new RuleNotFoundException($name, 0, $e);
        }
        if (!$rule instanceof RuleInterface) {
            throw new RuleInterfaceNotImplementedException($name);
        }
        $this->instances[$name] = $rule;
    }
    return $this->instances[$name];
}