/** * @param $class \ReflectionClass * ��ȡController��Action */ private function getActions($class) { $result = []; foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { $methodName = $method->getName(); if (strpos($methodName, 'action') === 0 && $methodName !== 'actions') { $method = new \ReflectionMethod($class->getName(), $methodName); $doc = DocHelper::getDocComment($method->getDocComment()); $result[str_replace("action", "", $methodName)] = $doc ? $doc : $methodName; } } return $result; }
/** * @param $class \ReflectionClass * ��ȡController��Action */ private function getActions($class) { $result = []; foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { $methodName = $method->getName(); $id = str_replace("action", "", $methodName); //只筛选index的action if (strpos($methodName, 'action') === 0 && $methodName !== 'actions' && in_array($id, ['Index'])) { $method = new \ReflectionMethod($class->getName(), $methodName); $doc = DocHelper::getDocComment($method->getDocComment()); $result[$id] = $doc ? $doc : $methodName; } } return $result; }