Exemplo n.º 1
0
 public function getRoutes()
 {
     $result = [];
     foreach ($this->annotationParser->getMethods(PluginRoute::ROUTE_ANNOTATION) as $method => $list) {
         foreach ($this->getRoutesForMethod($method, $list) as $data) {
             $result[] = sprintf("\t\t\$router->add('%s', ['module' => '%s', 'controller' => '%s', 'action' => '%s'], %s);\n", $data['path'], $this->module, $this->getControllerName(), $data['action'], is_null($data['method']) ? 'null' : '\'' . $data['method'] . '\'');
         }
     }
     return $result;
 }
Exemplo n.º 2
0
 public function getListeners()
 {
     $result = [];
     foreach ($this->annotationParser->getMethods(PluginListener::EVENT_ANNOTATION) as $method => $list) {
         $eventName = $this->findEventName($list);
         if (is_null($eventName)) {
             \mirolabs\phalcon\Framework\Logger::getInstance()->warning("Annotation Listener must have event name @Listener('event.name)'");
             continue;
         }
         $line = sprintf("\t\t\$di->get('listener')->attach('%s', function(\$event, \$component, \$param) use (\$di) {\n", $eventName);
         $line .= sprintf("\t\t\t\$di->get('%s')->%s(\$event, \$component, \$param);\n\t\t});\n", $this->getServiceName(), $method);
         $result[] = $line;
     }
     return $result;
 }
Exemplo n.º 3
0
 public function getTasks()
 {
     $result = [];
     foreach ($this->annotationParser->getMethods(PluginTask::METHOD_ANNOTATION) as $method => $list) {
         $taskAnnotation = $this->findTaskAnnotation($list);
         $command = $taskAnnotation->getArgument(PluginTask::METHOD_ANNOTATION_COMMAND);
         $description = $taskAnnotation->getArgument(PluginTask::METHOD_ANNOTATION_DESCRIPTION);
         $group = $taskAnnotation->getArgument(PluginTask::METHOD_ANNOTATION_GROUP);
         if (strpos($method, 'Action') == strlen($method) - 6) {
             $action = substr($method, 0, strlen($method) - 6);
         } else {
             Logger::getInstance()->warning("Method must have Action sufix");
             continue;
         }
         if (is_null($command)) {
             Logger::getInstance()->warning("Annotation Task must have attribute command @Task(command='<command_name>')");
             continue;
         }
         $line = sprintf("\t\t\t['%s']=>['class'=>'%s','action'=>'%s','description'=>'%s','group' => '%s']\n", $command, $this->className, $action, $description, $group);
         $result[] = $line;
     }
     return $result;
 }