getServiceLocator()->has($actionIdentifier)) { $action = $this->getServiceManager()->get($actionIdentifier); } elseif (class_exists($actionIdentifier) && is_subclass_of($actionIdentifier, Action::class)) { $action = new $actionIdentifier(); $this->propagate($action); } else { throw new ResolutionException('Unknown action ' . $actionIdentifier); } return $action; } public function getAvailableActions() { $actions = $this->getCache()->get(__FUNCTION__); if (is_null($actions)) { $actions = []; foreach ($this->getServiceLocator()->get(common_ext_ExtensionsManager::SERVICE_ID)->getInstalledExtensions() as $ext) { $actions = array_merge($actions, $this->getActionsInDirectory($ext->getDir())); } $actions = array_merge($actions, $this->getActionsInDirectory(VENDOR_PATH . 'oat-sa')); $this->getCache()->set(__FUNCTION__, $actions); } return $actions; } protected function getCache(): SimpleCache { return $this->getServiceLocator()->get(SimpleCache::SERVICE_ID); } protected function getActionsInDirectory($dir) { $classNames = []; $recIt = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir)); $regexIt = new \RegexIterator($recIt, '/^.+\.php$/i', \RecursiveRegexIterator::GET_MATCH); foreach ($regexIt as $entry) { $info = \helpers_PhpTools::getClassInfo($entry[0]); $fullname = empty($info['ns']) ? $info['class'] : $info['ns'] . '\\' . $info['class']; if (!in_array($fullname, self::$blackList) && is_subclass_of($fullname, Action::class)) { $classNames[] = $fullname; } } return $classNames; } }