Get a description of the action

@param string $controllerClassName
@param string $actionName
@return ActionDescription
@throws ActionNotFoundException
506956
public function getActionDescription($controllerClassName, $actionName) {

        if (!class_exists($controllerClassName) || !method_exists($controllerClassName, $actionName)) {
            throw new ActionNotFoundException('Unknown '.$controllerClassName.'@'.$actionName);
        }

        $reflector = new \ReflectionMethod($controllerClassName, $actionName);
        return new ActionDescription($reflector);
    }
165417
protected function getControllerMiddleware($actionName)
	{
		Controller::setRouter($this->laravel['router']);

		$segments = explode('@', $actionName);

		return $this->getControllerMiddlewareFromInstance(
			$this->laravel->make($segments[0]), $segments[1]
		);
	}
1356022
public function describeMachineAction($action, $field = null)
	{
		if ($field === null) {
			return @ $this->actions[$action];
		} else {
			return @ $this->actions[$action][$field];
		}
	}
77846
public function loadMetadataForAction($controllerClassName, $actionMethod)
    {
        $key = $controllerClassName . '_' . $actionMethod;
        if (array_key_exists($key, $this->classAnnotations)) {
            return $this->classAnnotations[$key];
        }

        $r = new \ReflectionClass($controllerClassName);
        $rMethod = $r->getMethod($actionMethod);

        $metadata = new Metadata();


        /** @var Annotation\WorkflowDispatch|null $workflowDispatchAnnotation */
        $workflowDispatchAnnotation = $this->getReader()->getMethodAnnotation($rMethod, Annotation\WorkflowDispatch::class);
        if (null !== $workflowDispatchAnnotation) {
            $metadata->setWorkflowDispatch($workflowDispatchAnnotation->enabled);
            $metadata->setWorkflowRunType($workflowDispatchAnnotation->activity);
        }

        /** @var Annotation\PrepareData|null $prepareDataAnnotation */
        $prepareDataAnnotation = $this->getReader()->getMethodAnnotation($rMethod, Annotation\PrepareData::class);
        if ($prepareDataAnnotation) {
            $metadata->setFlagRunPrepareData($prepareDataAnnotation->enabled);
            $metadata->setPrepareDataMethod($prepareDataAnnotation->type);
            $metadata->setPrepareDataHandler($prepareDataAnnotation->handler);
        }


        /** @var Annotation\DispatchConditions|null $dispatchConditionsAnnotation */
        $dispatchConditionsAnnotation = $this->getReader()->getMethodAnnotation($rMethod, Annotation\DispatchConditions::class);
        if ($dispatchConditionsAnnotation && is_array($dispatchConditionsAnnotation->conditions) && count($dispatchConditionsAnnotation->conditions) > 0) {
            $metadata->setFlagHasConditions(true);
            foreach ($dispatchConditionsAnnotation->conditions as $condition) {
                if (!$condition instanceof Condition) {
                    $errMsg = 'Invalid condition annotation';
                    throw new Exception\AnnotationReaderException($errMsg);
                }
                $conditionMetadata = new DispatchConditionMetadata($condition->type, $condition->handler, $condition->params);

                $metadata->addConditions($conditionMetadata);
            }
        }
//
//        /** @var Annotation\WorkflowRouterMap|null $workflowRouterMapAnnotation */
//        $workflowRouterMapAnnotation = $this->getReader()->getMethodAnnotation($rMethod, Annotation\WorkflowRouterMap::class);
//        if ($workflowRouterMapAnnotation) {
//            $metadata->setWorkflowManagerNameRouterParam($workflowRouterMapAnnotation->managerName);
//            $metadata->setWorkflowActionNameRouterParam($workflowRouterMapAnnotation->actionName);
//            $metadata->setWorkflowNameRouterParam($workflowRouterMapAnnotation->name);
//            $metadata->setEntryIdRouterParam($workflowRouterMapAnnotation->entryId);
//        }
//
//        $metadata->validate();

        return $metadata;
    }
225225
protected function definingClassForAction($action)
    {
        $definingClass = parent::definingClassForAction($action);
        if ($definingClass) {
            return $definingClass;
        }

        $class = static::class;
        while ($class != 'SilverStripe\\Control\\RequestHandler') {
            $templateName = strtok($class, '_') . '_' . $action;
            if (SSViewer::hasTemplate($templateName)) {
                return $class;
            }

            $class = get_parent_class($class);
        }

        return null;
    }
984652
public function matchesControllerActionPair($controllerObjectName, $actionName)
    {
        $controllerActionPairs = $this->getControllerActionPairs();
        return isset($controllerActionPairs[$controllerObjectName]) && in_array($actionName, $controllerActionPairs[$controllerObjectName]);
    }
914050
public function getActionByName(WorkflowDescriptor $wf, $actionName)
    {
        $actionName = (string)$actionName;

        foreach ($wf->getGlobalActions() as $actionDescriptor) {
            if ($actionName === $actionDescriptor->getName()) {
                return $actionDescriptor;
            }
        }

        foreach ($wf->getSteps() as $stepDescriptor) {
            $actions = $stepDescriptor->getActions();
            foreach ($actions as $actionDescriptor) {
                if ($actionName === $actionDescriptor->getName()) {
                    return $actionDescriptor;
                }
            }
        }

        foreach ($wf->getInitialActions() as $actionDescriptor) {
            if ($actionName === $actionDescriptor->getName()) {
                return $actionDescriptor;
            }
        }

        return null;
    }
228588
public function explainAction($actionName, $format)
    {
        $adapter = $this->getAdapter($format);
        $action = $this->getExecutor($actionName);

        if (!$action->supports($format)) {
            throw new \Exception('This action is not supported for the '.$format.' format.');
        }

        $schema = $action->getSchema();

        if (array_key_exists('$root', $schema)) {
            $jsonSchema = $this->serializer->getSchema($schema['$root']);

            if ($jsonSchema) {
                return $adapter->explainSchema($jsonSchema, $action->getMode());
            }
        }

        $identifiersSchema = [];

        foreach ($schema as $prop => $value) {
            if ($this->serializer->has($value)) {
                $identifiersSchema[$prop] = $this->serializer->getSchema($value);
            } else {
                $identifiersSchema[$prop] = $value;
            }
        }

        return $adapter->explainIdentifiers($identifiersSchema);
    }
1289545
private function _getRoute( $controller_name, $action_name )
    {
        $_route = $this->_createRoute( $controller_name, $action_name );

        foreach( $this->_routes as $route )
        {
            if ( $route->getControllerName() == $_route->getControllerName() && $route->getActionName() == $_route->getActionName() )
            {
                return $route;
            }
        }
    }
701725
protected function getTemplateSource($actionName = null)
    {
        if ($this->templateSource === null && $this->templatePathAndFilename === null) {
            throw new Exception\InvalidTemplateResourceException('No template has been specified. Use either setTemplateSource() or setTemplatePathAndFilename().', 1288085266);
        }
        if ($this->templateSource === null) {
            if (!is_file($this->templatePathAndFilename)) {
                throw new Exception\InvalidTemplateResourceException('Template could not be found at "' . $this->templatePathAndFilename . '".', 1288087061);
            }
            $this->templateSource = file_get_contents($this->templatePathAndFilename);
        }
        return $this->templateSource;
    }
542230
function findControllerForView ($viewName)
  {
    /** @var DocumentContext $this */
    $path = $this->viewService->resolveTemplatePath ($viewName, $base);
//    inspect ($viewName, $base, $path);
    if (isset($this->controllers[$path]))
      return $this->controllers[$path];

    foreach ($this->controllerNamespaces as $nsPath => $ns) {
//      inspect ($nsPath, $ns);
      if (str_beginsWith ($path, $nsPath)) {
        $remaining = substr ($path, strlen ($nsPath) + 1);
        $a         = PS ($remaining)->split ('/');
        $file      = $a->pop ();
        $nsPrefix  = $a->map ('ucfirst', false)->join ('\\')->S;
        $class     = ($p = strpos ($file, '.')) !== false
          ? ucfirst (substr ($file, 0, $p))
          : ucfirst ($file);
        $FQN       = PA ([$ns, $nsPrefix, $class])->prune ()->join ('\\')->S;
//        inspect ("CLASS $FQN");
        if (class_exists ($FQN))
          return $FQN;
      }
    }
//    inspect ("CLASS NOT FOUND FOR VIEW $viewName");
    return null;
  }
191752
public function getAction()
    {
        if (isset($this->uris[1])) {
            $_action = $this->uris[1];
        } else {
            throw new NotFoundException('Cannot dispatch action name.');
        }

        return strip_tags($_action);
    }
231168
public function addActionTriggerFeature($actionName, $eventLabel = ScriptLabel::MOUSECLICK)
    {
        $actionTrigger = new ActionTrigger($actionName, $this, $eventLabel);
        $this->addScriptFeature($actionTrigger);
        return $this;
    }
1354564
protected function isActionAllowed($actionName)
    {
        switch ($actionName) {
            // autocomplete action is mapped to list action for access permissions
            case 'autocomplete':
            // embeddedList action is mapped to list action for access permissions
            case 'embeddedList':
                $actionName = 'list';
                break;
            // newAjax action is mapped to new action for access permissions
            case 'newAjax':
                $actionName = 'new';
                break;
            default:
                break;
        }

        // Get item for edit/show or custom actions => security voters may apply
        $easyadmin = $this->request->attributes->get('easyadmin');
        $subject = $easyadmin['item'] ?? null;
        $this->get(AdminAuthorizationChecker::class)->checksUserAccess($this->entity, $actionName, $subject);

        return parent::isActionAllowed($actionName);
    }
1318404
public static function getControllerAccess($controllerClassName)
    {
        try{
            $returnValue = self::getCacheImplementation()->get(self::SERIAL_PREFIX_MODULE.$controllerClassName);
        } catch (\common_cache_Exception $e) {
            
            $extId = MapHelper::getExtensionFromController($controllerClassName);
            $extension = MapHelper::getUriForExtension($extId);
            $module = MapHelper::getUriForController($controllerClassName);
            
            $roleClass = new \core_kernel_classes_Class(GenerisRdf::CLASS_ROLE);
            $accessProperty = new \core_kernel_classes_Property(AccessService::PROPERTY_ACL_GRANTACCESS);

            $returnValue = array('module' => array(), 'actions' => array());
            
            // roles by extensions
            $roles = $roleClass->searchInstances(array(
                    $accessProperty->getUri() => $extension
                ), array(
                    'recursive' => true, 'like' => false
            ));
            foreach ($roles as $grantedRole) {
                $returnValue['module'][] = $grantedRole->getUri();
            }
            
            // roles by controller
            $filters = array(
                $accessProperty->getUri() => $module
            );
            $options = array('recursive' => true, 'like' => false);
            
            foreach ($roleClass->searchInstances($filters, $options) as $grantedRole){
                $returnValue['module'][] = $grantedRole->getUri();
            }
            
            // roles by action
            foreach (ControllerHelper::getActions($controllerClassName) as $actionName) {
                $actionUri = MapHelper::getUriForAction($controllerClassName, $actionName);
                $rolesForAction = $roleClass->searchInstances(array(
                    $accessProperty->getUri() => $actionUri
                ), array('recursive' => true, 'like' => false));
                if (!empty($rolesForAction)) {
                    $actionName = MapHelper::getActionFromUri($actionUri);
                    $returnValue['actions'][$actionName] = array();
                    foreach ($rolesForAction as $roleResource) {
                        $returnValue['actions'][$actionName][] = $roleResource->getUri();
                    }
                }
            }
            
            self::getCacheImplementation()->put($returnValue, self::SERIAL_PREFIX_MODULE.$controllerClassName);
        }
        return $returnValue;
    }
999869
protected function execPageAction($actionName, $parameters)
    {
        $result = null;

        if (!$this->actionExists($actionName)) {
            if (Config::get('app.debug', false)) {
                throw new SystemException(sprintf(
                    "Action %s is not found in the controller %s",
                    $actionName,
                    get_class($this)
                ));
            } else {
                Response::make(View::make('backend::404'), 404);
            }
        }

        // Execute the action
        $result = call_user_func_array([$this, $actionName], $parameters);

        // Expecting \Response and \RedirectResponse
        if ($result instanceof \Symfony\Component\HttpFoundation\Response) {
            return $result;
        }

        // No page title
        if (!$this->pageTitle) {
            $this->pageTitle = 'backend::lang.page.untitled';
        }

        // Load the view
        if (!$this->suppressView && $result === null) {
            return $this->makeView($actionName);
        }

        return $this->makeViewContent($result);
    }
867274
protected function _getCommands($controllerName)
    {
        $commands = [];

        foreach (get_class_methods($controllerName) as $method) {
            if (preg_match('#^(.*)Command$#', $method, $match) === 1 && $match[1] !== 'help') {
                $commands[] = $match[1];
            }
        }

        return $commands;
    }