/** * Add the Annotated Method to the Navigation * * @param \TYPO3\FLOW3\AOP\JoinPointInterface $joinPoint * @FLOW3\Before("method(public .*\Controller\.*Controller->.*Action(.*))") * @return void */ public function addNavigationitem(\TYPO3\FLOW3\AOP\JoinPointInterface $joinPoint) { $currentClassName = $joinPoint->getClassName(); $currentMethodName = $joinPoint->getMethodName(); $controllers = $this->reflectionService->getAllSubClassNamesForClass("\\TYPO3\\FLOW3\\MVC\\Controller\\ActionController"); foreach ($controllers as $className) { $methods = get_class_methods($className); if (is_array($methods)) { foreach ($methods as $methodName) { if ($this->reflectionService->isMethodAnnotatedWith($className, $methodName, "Admin\\Annotations\\Navigation")) { $annotations = $this->reflectionService->getMethodAnnotations($className, $methodName, "Admin\\Annotations\\Navigation"); foreach ($annotations as $annotation) { $action = str_replace("Action", "", $methodName); $controller = $this->helper->getControllerByClassName($className); $package = $this->objectManager->getPackageKeyByObjectName($className); $arguments = array("action" => $action, "controller" => $controller, "package" => $package); $title = !is_null($annotation->title) ? $annotation->title : sprintf("%s (%s)", $controller, $action); \Admin\Core\API::addNavigationitem($title, $annotation->position, $arguments, $annotation->priority, $annotation->parent); } } } } } $settings = $this->helper->getSettings("Admin.Navigation"); foreach ($settings as $position => $items) { foreach ($items as $title => $conf) { $priority = isset($conf["priority"]) ? $conf["priority"] : 100; $arguments = $conf["Arguments"]; \Admin\Core\API::addNavigationitem($title, strtolower($position), $arguments, $priority); } } }
/** * Explicitly sets the object name of the controller * * @param string $unknownCasedControllerObjectName The fully qualified controller object name * @return void * @throws \TYPO3\FLOW3\Object\Exception\UnknownObjectException * @api */ public function setControllerObjectName($unknownCasedControllerObjectName) { $controllerObjectName = $this->objectManager->getCaseSensitiveObjectName($unknownCasedControllerObjectName); if ($controllerObjectName === FALSE) { throw new \TYPO3\FLOW3\Object\Exception\UnknownObjectException('The object "' . $unknownCasedControllerObjectName . '" is not registered.', 1268844071); } $this->controllerPackageKey = $this->objectManager->getPackageKeyByObjectName($controllerObjectName); $matches = array(); $subject = substr($controllerObjectName, strlen($this->controllerPackageKey) + 1); preg_match('/ ^( Controller | (?P<subpackageKey>.+)\\\\Controller ) \\\\(?P<controllerName>[a-z\\\\]+)Controller $/ix', $subject, $matches); $this->controllerSubpackageKey = isset($matches['subpackageKey']) ? $matches['subpackageKey'] : NULL; $this->controllerName = $matches['controllerName']; }
/** * * @param $model String Name of the Model with Namespace * @return $name String Model Name * @author Marc Neuhaus <*****@*****.**> **/ public function getPackageByClassName($model) { return $this->objectManager->getPackageKeyByObjectName($model); }