/var/www/vhosts/ihelp.ro/httpdocs/vendor/cakedc/auth/src/Rbac/Rules
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/cakedc/auth/src/Rbac/Rules/AbstractRule.php (3325B)
setConfig($config);
}
/**
* Get a table from the alias, table object or inspecting the request for a default table
*
* @param \Psr\Http\Message\ServerRequestInterface $request request
* @param mixed $table table
* @return \Cake\ORM\Table
*/
protected function _getTable(ServerRequestInterface $request, $table = null)
{
if (empty($table)) {
return $this->_getTableFromRequest($request);
}
if ($table instanceof Table) {
return $table;
}
return TableRegistry::getTableLocator()->get($table);
}
/**
* Inspect the request and try to retrieve a table based on the current controller
*
* @param \Psr\Http\Message\ServerRequestInterface $request request
* @return \Cake\ORM\Table
* @throws \OutOfBoundsException if table alias can't be extracted from request
*/
protected function _getTableFromRequest(ServerRequestInterface $request)
{
$params = $request->getAttribute('params');
$plugin = $params['plugin'] ?? null;
$controller = $params['controller'] ?? null;
$modelClass = ($plugin ? $plugin . '.' : '') . $controller;
$this->modelFactory('Table', function (string $alias, array $options): \Cake\ORM\Table {
return $this->getTableLocator()->get($alias, $options);
});
if (empty($modelClass)) {
throw new OutOfBoundsException('Missing Table alias, we could not extract a default table from the request');
}
return $this->loadModel($modelClass);
}
/**
* Check the current entity is owned by the logged in user
*
* @param array|\ArrayAccess $user Auth array with the logged in data
* @param string $role role of the user
* @param \Psr\Http\Message\ServerRequestInterface $request current request, used to get a default table if not provided
* @return bool
* @throws \OutOfBoundsException if table is not found or it doesn't have the expected fields
*/
abstract public function allowed($user, $role, ServerRequestInterface $request);
}