src/ViKon/Auth/RouterAuth.php
public function getPermissions($name)
    {
        $route = $this->router->getRoutes()->getByName($name);

        // If route not exists, return NULL
        if ($route === null) {
            return null;
        }

        $permissions = [];

        // Get permission from permission middleware
        foreach ($route->middleware() as $middleware) {
            if (strpos($middleware, 'permission:') === 0) {
                list(, $permission) = explode(':', $middleware, 2);
                $permissions[] = $permission;
            }
        }

        // Get permissions from array syntax
        $action = $route->getAction();

        if (array_key_exists('permission', $action)) {
            $permissions[] = $action['permission'];
        }

        if (array_key_exists('permissions', $action)) {
            $permissions = array_merge($permissions, $action['permissions']);
        }

        return array_unique($permissions);
    }
public function getPermissions($name)
    {
        $route = $this->router->getRoutes()->getByName($name);

        // If route not exists, return NULL
        if ($route === null) {
            return null;
        }

        $permissions = [];

        // Get permission from permission middleware
        foreach ($route->middleware() as $middleware) {
            if (strpos($middleware, 'permission:') === 0) {
                list(, $permission) = explode(':', $middleware, 2);
                $permissions[] = $permission;
            }
        }

        // Get permissions from array syntax
        $action = $route->getAction();

        if (array_key_exists('permission', $action)) {
            $permissions[] = $action['permission'];
        }

        if (array_key_exists('permissions', $action)) {
            $permissions = array_merge($permissions, $action['permissions']);
        }

        return array_unique($permissions);
    }
public function getPermissions ( $ name ) { $ route = $ this -> router -> getRoutes ( ) -> getByName ( $ name ) ; // If route not exists, return NULL if ( $ route === null ) { return null ; } $ permissions = [ ] ; // Get permission from permission middleware foreach ( $ route -> middleware ( ) as $ middleware ) { if ( strpos ( $ middleware , 'permission:' ) === 0 ) { list ( , $ permission ) = explode ( ':' , $ middleware , 2 ) ; $ permissions [ ] = $ permission ; } } // Get permissions from array syntax $ action = $ route -> getAction ( ) ; if ( array_key_exists ( 'permission' , $ action ) ) { $ permissions [ ] = $ action [ 'permission' ] ; } if ( array_key_exists ( 'permissions' , $ action ) ) { $ permissions = array_merge ( $ permissions , $ action [ 'permissions' ] ) ; } return array_unique ( $ permissions ) ; }
Get permissions for named route

@param string $name named route named

@return string[]|null NULL if route not found, otherwise array of permissions
Get permissions for named route