Final Class Yiisoft\Rbac\Rules\Container\RulesContainer
| Inheritance | Yiisoft\Rbac\Rules\Container\RulesContainer |
|---|---|
| Implements | Yiisoft\Rbac\RuleFactoryInterface |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Rbac\Rules\Container\RulesContainer | |
| create() | Yiisoft\Rbac\Rules\Container\RulesContainer |
Method Details
| 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);
}
| 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];
}
Signup or Login in order to comment.