Class OrmResolver
Policy resolver that applies conventions based policy classes for CakePHP ORM Tables, Entities and Queries.
Property Summary
-
$appNamespace protected
string
Application namespace.
-
$container protected
Cake\Core\ContainerInterface|null
The DIC instance from the application
-
$overrides protected
array<string, string>
Plugin name overrides.
Method Summary
-
__construct() public
Constructor
-
findPolicy() protected
Locate a policy class using conventions
-
getEntityPolicy() protected
Get a policy for an entity
-
getNamespace() protected
Returns plugin namespace override if exists.
-
getPolicy() public
Get a policy for an ORM Table, Entity or Query.
-
getRepositoryPolicy() protected
Get a policy for a table
Method Detail
__construct() ¶ public
__construct(string $appNamespace = 'App', array<string, string> $overrides = [], Cake\Core\ContainerInterface|null $container = null)
Constructor
Parameters
-
string
$appNamespace optional The application namespace
-
array<string, string>
$overrides optional A list of plugin name overrides.
-
Cake\Core\ContainerInterface|null
$container optional The DIC instance from the application
findPolicy() ¶ protected
findPolicy(string $class, string $name, string $namespace): mixed
Locate a policy class using conventions
Parameters
-
string
$class The full class name.
-
string
$name The name suffix of the resource.
-
string
$namespace The namespace to find the policy in.
Returns
mixed
Throws
Authorization\Policy\Exception\MissingPolicyException
When a policy for the resource has not been defined.
getEntityPolicy() ¶ protected
getEntityPolicy(Cake\Datasource\EntityInterface $entity): mixed
Get a policy for an entity
Parameters
-
Cake\Datasource\EntityInterface
$entity The entity to get a policy for
Returns
mixed
getNamespace() ¶ protected
getNamespace(string $namespace): string
Returns plugin namespace override if exists.
Parameters
-
string
$namespace The namespace to find the policy in.
Returns
string
getPolicy() ¶ public
getPolicy(mixed $resource): mixed
Get a policy for an ORM Table, Entity or Query.
The resolver MUST throw the \Authorization\Policy\Exception\MissingPolicyException
exception if a policy cannot be resolved for a given resource.
Parameters
-
mixed
$resource The resource.
Returns
mixed
Throws
Authorization\Policy\Exception\MissingPolicyException
When a policy for the resource has not been defined or cannot be resolved.
getRepositoryPolicy() ¶ protected
getRepositoryPolicy(Cake\Datasource\RepositoryInterface $table): mixed
Get a policy for a table
Parameters
-
Cake\Datasource\RepositoryInterface
$table The table/repository to get a policy for.
Returns
mixed