Get the action and controller from the wildcard router

@return array action,controller
545898
protected function dectectFromWildcardRouter()
    {
        $wildcard = App::make('decoy.wildcard');

        // Attach / detach are ACL-ed by the parent controller.  It's the one being
        // touched,
        $action = $wildcard->detectAction();
        if (in_array($action, ['attach', 'remove'])) {
            $controller = request('parent_controller');
            $action = 'update';

        // Otherwise, use the controller from the route
        } else {
            $controller = $wildcard->detectControllerName();
        }

        // Further mapping of the action
        $action = $this->mapActionToPermission($action);

        // Return the detected action and controller
        return [$action, $controller];
    }
1159187
public function getActions()
    {
        if(! $this->_actions) {
            $this->_actions = array();

            foreach ($this->getMethods() as $method) {
                if (substr($method, 0, 7) == '_action') {
                    $this->_actions[] = strtolower(substr($method, 7));
                }
            }

            $this->_actions = array_unique(array_merge($this->_actions, array_keys($this->_action_map)));
        }

        return $this->_actions;
    }
1049065
public function getRoutes() : array {
        $request = get_request();
        $requestMethod = $request->method();
        $requestPathParts = $request->pathParts();
        $routesIndex = $this->routesIndex;
        $routes = [];
        $this->getRoutesFromIndex($routes,$routesIndex, $requestMethod, $requestPathParts);
        return $routes;
    }
907502
public function getActions()
    {
        $this->beforeAction();
        $role = new \core_kernel_classes_Resource($this->getRequestParameter('role'));
        $included = array();
        foreach (\tao_models_classes_RoleService::singleton()->getIncludedRoles($role) as $includedRole) {
            $included[] = $includedRole->getUri();
        }
        $module = new \core_kernel_classes_Resource($this->getRequestParameter('module'));

        $controllerClassName = MapHelper::getControllerFromUri($module->getUri());
        $controllerAccess = CacheHelper::getControllerAccess($controllerClassName);

        $actions = array();
        foreach (ControllerHelper::getActions($controllerClassName) as $actionName) {
            $uri = MapHelper::getUriForAction($controllerClassName, $actionName);
            $part = explode('#', $uri);
            list($type, $extId, $modId, $actId) = explode('_', $part[1]);

            $allowedRoles = isset($controllerAccess['actions'][$actionName])
                ? array_merge($controllerAccess['module'], $controllerAccess['actions'][$actionName])
                : $controllerAccess['module'];

            $access = count(array_intersect($included, $allowedRoles)) > 0
                ? self::ACCESS_INHERITED
                : (in_array($role->getUri(), $allowedRoles)
                    ? self::ACCESS_FULL
                    : self::ACCESS_NONE);

            $actions[$actId] = array(
                'uri' => $uri,
                'access' => $access,
                'locked' => $this->isLocked(),
            );
        }

        ksort($actions);

        $this->returnJson($actions);
    }
409392
public function getRouteInfo()
    {
        if ($this->isSingle()) {
            if (isset($this->containers['route_info']) && ($controller = $this->containers['route_info']->get('controller')) 
                && ($action = $this->containers['route_info']->get('action'))
            ) {
                return ['controller' => $controller, 'action' => $action];
            }
        }
        return ['controller' => 'index', 'action' => 'index'];
    }
803763
public function routing()
    {
        // has dispatch.
        $route = null;
        if ($action = $this->getDispatchAction()) {
            $route = new Rule\MatchRule(array('action' => $action));
        }

        // root rule.
        $path = $this->request->getPath();
        if (! $route && $this->_root && $this->_root->match($path)) {
            $route = $this->_root;
        }

        // match rule.
        if (! $route) {
            foreach ($this->_rules as $rule) {
                if ($rule->match($path)) {
                    $route = $rule;
                    break;
                }
            }
        }

        // default rule.
        if (! $route && $this->_default && $this->_default->match($path)) {
            $route = $this->_default;
        }

        // not found
        if (! $route || ! $this->isActionExists($route)) {
            $route = new Rule\NotFoundRule();
        }
        return $route;
    }
1141437
public function getControllers()
    {
        $map = $this->map;
        $result = array();

        foreach ($map as $template => $options) {
            if (isset($options['controller'])) {
                $result[] = $options['controller'];
            }
        }

        return $result;
    }
178779
protected function getControllerMiddlewareFromInstance($controller, $method)
    {
        $middleware = $this->router->getMiddleware();

        $results = [];

        foreach ($controller->getMiddleware() as $name => $options) {
            if (!$this->methodExcludedByOptions($method, $options)) {
                $results[$name] = array_get($middleware, $name, $name);
            }
        }

        return $results;
    }
1174386
public function getDefaultActions()
    {
        /** @var ActiveController $owner */
        $owner = $this->owner;

        $defaultActions = $owner->actions();
        // set default indexes to avoid many isset() calls later
        $actions = [
            'index' => false,
            'view' => false,
            'print' => false,
            'update' => false,
            'delete' => false,
            'toggle' => false,
            'history' => false,
            'help' => false,
            'state' => false,
        ];
        $availableActions = array_merge($actions, $defaultActions);
        foreach ($availableActions as $action => $enabled) {
            $availableActions[$action] = $enabled && in_array($action, $this->buttons);
        }
        return $availableActions;
    }
857475
public function getAllModules()
    {
        $returnValue = array();

        // routes
        $namespaces = array();
        foreach ($this->getManifest()->getRoutes() as $mapedPath => $ns) {
            $namespaces[] = trim($ns, '\\');
        }
        if (!empty($namespaces)) {
        	common_Logger::d('Namespace not empty for extension '. $this->getId() );
            $recDir = new RecursiveDirectoryIterator($this->getDir());
            $recIt = new RecursiveIteratorIterator($recDir);
            $regexIt = new RegexIterator($recIt, '/^.+\.php$/i', RecursiveRegexIterator::GET_MATCH);
            foreach ($regexIt as $entry) {
                $info = helpers_PhpTools::getClassInfo($entry[0]);
                if (!empty($info['ns'])) {
                    $ns = trim($info['ns'], '\\');
                    if (!empty($info['ns']) && in_array($ns, $namespaces)) {
                        $returnValue[$info['class']] = $ns.'\\'.$info['class'];
                    }
                }
            }
        } 
        // legacy
        if ($this->hasConstant('DIR_ACTIONS') && file_exists($this->getConstant('DIR_ACTIONS'))) {
			$dir = new DirectoryIterator($this->getConstant('DIR_ACTIONS'));
		    foreach ($dir as $fileinfo) {
				if(preg_match('/^class\.[^.]*\.php$/', $fileinfo->getFilename())) {
					$module = substr($fileinfo->getFilename(), 6, -4);
					$returnValue[$module] = $this->getId().'_actions_'.$module;
				}
			}
        }
        
        // validate the classes
        foreach (array_keys($returnValue) as $key) {
            $class = $returnValue[$key];
            if (!class_exists($class)) {
				common_Logger::w($class.' not found');
				unset($returnValue[$key]);
            } elseif (!is_subclass_of($class, 'Module')) {
				common_Logger::w($class.' does not inherit Module');
				unset($returnValue[$key]);
            } 
        }
        
        return (array) $returnValue;
    }
1147781
protected function getActionRoutes($controller, &$result)
    {
        $token = "Get actions of controller '" . $controller->uniqueId . "'";
        Yii::beginProfile($token, __METHOD__);
        try {
            $prefix = '/' . $controller->uniqueId . '/';
            foreach ($controller->actions() as $id => $value) {
                $result[$prefix . $id] = $prefix . $id;
            }
            $class = new \ReflectionClass($controller);
            foreach ($class->getMethods() as $method) {
                $name = $method->getName();
                if ($method->isPublic() && !$method->isStatic() && strpos($name, 'action') === 0 && $name !== 'actions') {
                    $name = strtolower(preg_replace('/(?<![A-Z])[A-Z]/', ' \0', substr($name, 6)));
                    $id = $prefix . ltrim(str_replace(' ', '-', $name), '-');
                    $result[$id] = $id;
                }
            }
        } catch (\Exception $exc) {
            Yii::error($exc->getMessage(), __METHOD__);
        }
        Yii::endProfile($token, __METHOD__);
    }
1079104
protected function getRoutes()
    {
        $c = self::ROUTE_PATTERN_CONTROLLER;
        $a = self::ROUTE_PATTERN_ACTION;
        $p = self::ROUTE_PATTERN_PARAMS;
        return array(
            "/" => self::MATCHES_NOTHING,
            "/$c" => self::MATCHES_CONTROLLER,
            "/$c/" => self::MATCHES_CONTROLLER,
            "/$c/$a" => self::MATCHES_CONTROLLER_AND_ACTION,
            "/$c/$a/" => self::MATCHES_CONTROLLER_AND_ACTION,
            "/$c/$a/$p" => self::MATCHES_CONTROLLER_ACTION_AND_PARAMS
        );
    }
948103
protected function _getControllerActions()
    {
        $table = $entity = [];

        $actions = $this->_getAllowedActions();
        foreach ($actions as $actionName => $config) {
            list($scope, $actionConfig) = $this->_getControllerActionConfiguration($actionName, $config);
            ${$scope}[$actionName] = $actionConfig;
        }

        $actionBlacklist = [];
        $groups = $this->_action()->getConfig('scaffold.action_groups') ?: [];
        foreach ($groups as $group) {
            $group = Hash::normalize($group);
            foreach ($group as $actionName => $config) {
                if (isset($table[$actionName]) || isset($entity[$actionName])) {
                    continue;
                }
                if ($config === null) {
                    $config = [];
                }
                list($scope, $actionConfig) = $this->_getControllerActionConfiguration($actionName, $config);
                $realAction = Hash::get($actionConfig, 'url.action', $actionName);
                if (!isset(${$scope}[$realAction])) {
                    continue;
                }

                $actionBlacklist[] = $realAction;
                ${$scope}[$actionName] = $actionConfig;
            }
        }

        foreach ($actionBlacklist as $actionName) {
            unset($table[$actionName]);
            unset($entity[$actionName]);
        }

        return compact('table', 'entity');
    }
661272
public static function build($controller)
    {
        $routes = array();
        $actions = self::parseActionMethods($controller);

        foreach ($actions as $actionName => $actionInfo) {
            list($annotations, $meta) = $actionInfo;

            if (isset($annotations['Route'])) {
                $path = $annotations['Route'];
            } else {
                if ($actionName === 'indexAction') {
                    $path = '';
                } else {
                    $path = self::translatePath($actionName); // '/' . preg_replace_callback('/[A-Z]/', function($matches) {
                }
            }

            $route = array($path, $actionName);

            if (isset($annotations['Method'])) {
                $route[] = array('method' => Mux::convertRequestMethodConstant($annotations['Method']));
            } else {
                $route[] = array();
            }
            $routes[] = $route;
        }

        return $routes;
    }
356884
private function getControllers ($dir = FALSE, $recursive = TRUE)
	{
		
		// Excluded Controllers

		$ignore		= array ('.', '..', '.svn', 'Developer.php');
		
		// Append / to dir if it doesnt end in one
		
		if ($dir && substr ($dir, -1) != '/')
		{
			$dir	.= DIRECTORY_SEPARATOR;
		}
		
		// Set path with seperator

		$path	= __DIR__ . DIRECTORY_SEPARATOR . $dir;
		
		// Extract Actual Controllers

		$controllers	= array ();
		
		foreach (scandir ($path) as $entry)
		{
			
			$name	= str_replace ('.php', '', $entry);
			
			// If the entry is . or .. move on
			
			if (in_array ($entry, $ignore))
			{
				continue;
			}
			
			// Else if the entry is a .php file
			
			else if (is_file ($path . $entry) && stripos ($entry, '.php'))
			{
				if (!array_key_exists ($name, $controllers))
				{
					$controllers[$name] = 0;
				}
			}
			
			// Else if we're calling recursively and the entry is a directory 
			
			else if ($recursive && is_dir ($path . $entry))
			{
				$controllers[$name] = $this->getControllers ($dir . $entry, TRUE);
			}
			
		}
		
		return $controllers;

	}
1307249
public function getControllerAndAction($controller, $action, $controllerDir = '')
    {
        $controller = $this->getControllerName($controller, $controllerDir);
        $action = $this->getActionName($action);

        return [$controller, $action];
    }
198892
public function GetActionName () {
		if ($this->actionName === NULL) {
			$routerClass = self::$routerClass;
			$router = & $routerClass::GetInstance();
			if (isset($this->globalGet[$router::URL_PARAM_ACTION])) 
				$this->actionName = $this->GetParam($router::URL_PARAM_ACTION, 'a-zA-Z0-9\-_', '', 'string');
		}
		return $this->actionName;
	}