const EXCLUDED_CONTROLLERS = [
'user',
'acl',
'resources',
'roles',
'users'
];
const EXCLUDED_ACTIONS = [
'login',
'logout'
];
/**
* Get available resources list
*/
public function getAvailableResources(): array
{
$resources = [];
$resources['*'][] = '*';
$controllersPaths = [
'/app/controllers/',
];
foreach ($controllersPaths as $path) {
foreach (glob(BASE_PATH . $path .'/*Controller.php') as $controller) {
$className = basename($controller, '.php');
$class = strtolower(str_replace('Controller', '', basename($controller, '.php')));
if (in_array($class, self::EXCLUDED_CONTROLLERS)) {
continue;
}
$resources[$class] = [];
$methods = (new \ReflectionClass($className))->getMethods(\ReflectionMethod::IS_PUBLIC);
foreach ($methods as $method) {
if (\Phalcon\Text::endsWith($method->name, 'Action')) {
$action = strtolower(str_replace('Action', '', $method->name));
if (in_array($action, self::EXCLUDED_ACTIONS)) {
continue;
}
$resources[$class][] = $action;
}
}
}
}
return $resources;
}
if (passwor_verify($data['password'], $users_log["pass"]) ) {
# code...
}
if (\Rapid\Migration::isPhalconRoute($_SERVER['REQUEST_URI'])) {
// то этот рут, обрабатывает фалкон.
}
/**
* Detects phalcon routes by uri
*
* @param $uri
* @return bool
*/
public static function isPhalconRoute($uri)
{
// Refactoring to phalcon (1:1 routes)
$phalconUris = array(
'/categories',
'/counter/itemhit',
'/counter/videohit',
'/counter/bloghit',
'/statistic/sales_views',
'/statistic/receive_vat',
'/contacts',
'/gallery',
'/blog',
'/pages',
'/users/login',
'/users/registration',
....
....
foreach ($phalconUris as $p_uri) {
if (strpos($uri, $p_uri) !== false) {
return true;
}
}
}