Map resource actions to resource abilities.

@throws \ReflectionException

@return array
518091
protected function mapResourceAbilities(): array
    {
        // Reflect calling controller
        $controller = new ReflectionClass(static::class);

        // Get public methods and filter magic methods
        $methods = array_filter($controller->getMethods(ReflectionMethod::IS_PUBLIC), function ($item) use ($controller) {
            return $item->class === $controller->name && mb_substr($item->name, 0, 2) !== '__' && ! in_array($item->name, $this->resourceActionWhitelist);
        });

        // Get controller actions
        $actions = array_combine($items = array_map(function ($action) {
            return $action->name;
        }, $methods), $items);

        // Map resource actions to resourse abilities
        array_walk($actions, function ($value, $key) use (&$actions) {
            $actions[$key] = array_get($this->resourceAbilityMap(), $key, $value);
        });

        return $actions;
    }
762849
public function prepareActionList()
    {
        Base::getLog()->debug(__METHOD__ . ' prepare action list for mapping - start');
        $actionSign = '';
        foreach (explode('-', $this->request->action) as $part)
        {
            $actionSign .= ucfirst($part);
        }

        $actions = [
            'action' . $actionSign,
        ];

        Base::getLog()->debug(__METHOD__ . ' prepare action list for mapping - end', [
            'actions' => $actions,
        ]);
        return $actions;
    }
59436
protected function getResourceMethodConfiguration(): array
    {
        return [
            ResourceMethodEnum::GET_ALL => RequestPathFormatEnum::TASKS,
            ResourceMethodEnum::GET_ALL_FOR_FOLDER => RequestPathFormatEnum::TASKS_FOR_FOLDER,
            ResourceMethodEnum::GET_BY_ID => RequestPathFormatEnum::TASKS_BY_ID,
            ResourceMethodEnum::GET_BY_IDS => RequestPathFormatEnum::TASKS_BY_IDS,
            ResourceMethodEnum::CREATE_FOR_FOLDER => RequestPathFormatEnum::TASKS_FOR_FOLDER,
            ResourceMethodEnum::UPDATE => RequestPathFormatEnum::TASKS_BY_ID,
            ResourceMethodEnum::DELETE => RequestPathFormatEnum::TASKS_BY_ID,
        ];
    }
138960
public function get_resources() {

        if (empty($this->resources)) {
            $this->resources = array();
            $this->resources[] = new \ltiservice_toolsettings\local\resources\systemsettings($this);
            $this->resources[] = new \ltiservice_toolsettings\local\resources\contextsettings($this);
            $this->resources[] = new \ltiservice_toolsettings\local\resources\linksettings($this);
        }

        return $this->resources;

    }
189411
private function getResources()
    {

        $resources = [];
        foreach( $this->getClassAnnotations() as $annotation ) {

            // is this a resource
            if( 0 === strpos($annotation, "resource") ) {
                $resources[] = explode(' ', $annotation)[1];
            }

        }

        return $resources;

    }
217692
public function getConnectionsFromResource() : Array
	{	
		$baseDir = dirname(__DIR__);
		$configLocation = $baseDir . '/config.php';
	
		if (!file_exists($configLocation) && class_exists(Config::class)) {
			$resourceConfig = Config::get('database');
		}else{
			$resourceConfig = include $configLocation;
		}

		if (gettype($resourceConfig) !== 'array') {
			throw new Exception('Invalid configuration type.');
		}
		
		return $resourceConfig;
	}
432044
public function behaviors() {

		$behaviors = parent::behaviors();

		$behaviors[ 'rbac' ][ 'actions' ][ 'gallery' ] = [ 'permission' => $this->crudPermission ];
		$behaviors[ 'rbac' ][ 'actions' ][ 'data' ] = [ 'permission' => $this->crudPermission ];
		$behaviors[ 'rbac' ][ 'actions' ][ 'config' ] = [ 'permission' => $this->crudPermission ];
		$behaviors[ 'rbac' ][ 'actions' ][ 'settings' ] = [ 'permission' => $this->crudPermission ];

		$behaviors[ 'verbs' ][ 'actions' ][ 'gallery' ] = [ 'get' ];
		$behaviors[ 'verbs' ][ 'actions' ][ 'data' ] = [ 'get', 'post' ];
		$behaviors[ 'verbs' ][ 'actions' ][ 'config' ] = [ 'get', 'post' ];
		$behaviors[ 'verbs' ][ 'actions' ][ 'settings' ] = [ 'get', 'post' ];

		$behaviors[ 'activity' ] = [
			'class' => ActivityBehavior::class,
			'admin' => true,
			'create' => [ 'create' ],
			'update' => [ 'update' ],
			'delete' => [ 'delete' ]
		];

		return $behaviors;
	}
17966
protected function getResources() {

        if (empty($this->resources)) {

            // On initialise les variables
            $resources = array();
            $actions   = $this->getActions();

            // On parcourt les sections et on en crée des ressources.
            foreach ($actions as $section) {
                $resources[$section->name] = new Resource($section->name);
            }

            $this->resources = $resources;

        }

        return $this->resources;

    }
1113941
public static function getActions(\core_kernel_classes_Resource $module)
    {
        $returnValue = array();
        $controllerClassName = MapHelper::getControllerFromUri($module->getUri());
        try {
            foreach (ControllerHelper::getActions($controllerClassName) as $actionName) {
                $uri = MapHelper::getUriForAction($controllerClassName, $actionName);
                $returnValue[$uri] = new \core_kernel_classes_Resource($uri);
            }
        } catch (\ReflectionException $e) {
            // unknown controller, no actions returned
        }
        return (array) $returnValue;
    }
952395
public function rawObjectActions()
    {
        if ($this->objectActions === null) {
            $parsed = $this->parsedObjectActions;

            $collectionConfig = $this->collectionConfig();
            if (isset($collectionConfig['object_actions'])) {
                $actions = $collectionConfig['object_actions'];
            } else {
                $actions = [];
            }

            $this->setObjectActions($actions);

            $this->parsedObjectActions = $parsed;
        }

        if ($this->parsedObjectActions === false) {
            $this->parsedObjectActions = true;
            $this->objectActions = $this->createObjectActions($this->objectActions);
        }

        return $this->objectActions;
    }
1013927
public function get_resources() {

        if (empty($this->resources)) {
            $this->resources = array();
            $this->resources[] = new \ltiservice_memberships\local\resources\contextmemberships($this);
            $this->resources[] = new \ltiservice_memberships\local\resources\linkmemberships($this);
        }

        return $this->resources;

    }
893151
public function get_resources() {

        if (empty($this->resources)) {
            $this->resources = array();
            $this->resources[] = new \ltiservice_profile\local\resources\profile($this);
        }

        return $this->resources;

    }
1084899
public function resourceDesktop()
    {
        $resourceTypes = $this->em->getRepository('ClarolineCoreBundle:Resource\ResourceType')->findAll();
        $resourceActions = $this->em->getRepository('ClarolineCoreBundle:Resource\MenuAction')
            ->findByResourceType(null);

        return $this->templating->render(
            'ClarolineCoreBundle:Tool\desktop\resource_manager:resources.html.twig',
            array(
                'resourceTypes' => $resourceTypes,
                'resourceActions' => $resourceActions,
                'maxPostSize' => ini_get('post_max_size'),
                'resourceZoom' => $this->getZoom()
            )
        );
    }
1242130
public function actions()
    {
        $flag = [
            'actions',
            '__construct',
            '__toString',
            '__invoke',
            '__call',
            'offsetExists',
            'offsetGet',
            'offsetSet',
            'offsetUnset',
            '__get',
            '__set',
            '__isset',
            '__unset',
            'normalizeKey',
            'set',
            'get',
            'replace',
            'has',
            'remove',
            'getIterator',
        ];

        return [
            'classname' => get_class($this),
            'methods' => array_diff(get_class_methods($this), $flag),
            '_methods' => array_intersect(get_class_methods($this), $flag),
            '_sys' => array_intersect(get_class_methods($this), [
                'actions',
                'clear',
                'count',
                'all',
                'keys',
                'load'
            ]),
            '_config' => $class_vars = get_class_vars(get_class($this)),
        ];
    }
549281
final public function actionslistAction() {
		$reflection = new ReflectionObject($this);
		
		echo "Available actions:\033[1;32m";
		
		foreach ($reflection->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
			$length = strlen($method->name) - 6;
			
			if (strpos($method->name, 'Action') === $length) {
				echo ' ', substr($method->name, 0, $length);
			}
		}
		
		echo "\033[0m";
	}
441444
public function getResources()
    {
        $resources = array_map(function ($resource) {
            return is_array($resource) ? $resource : array($resource);
        }, $this->getRawResources());

        return $resources;
    }
213030
public function getVariables()
    {
        if (!$this->variables->count()) {
            return array();
        }

        // If credentials are not globally defined,
        // check if an action have credentials
        if (null === $this->getVariable('credentials')) {
            $this->variables->set('credentials', false);
            foreach (array_merge(array_values($this->getObjectActions()), array_values($this->getBatchActions())) as $action) {
                if ($action->getCredentials()) {
                    $this->variables->set('credentials', true);
                    break;
                }
            }
        }

        return parent::getVariables();
    }