示例#1
0
 public function parseFile(Annotations $adapter, $className, $module)
 {
     $parser = new AnnotationParser($adapter->get($className));
     if ($parser->isExistsAnnotationClass(self::CLASS_ANNOTATION)) {
         $this->tasks->add(new ModelTask($parser, $className));
     }
 }
示例#2
0
 public function parseFile(\Phalcon\Annotations\Adapter $adapter, $className, $module)
 {
     $parser = new AnnotationParser($adapter->get($className));
     if ($parser->isExistsAnnotationClass(self::CONTROLER_ANNOTATION)) {
         $this->routers->add(new ModelRoute($parser, $className, $module));
     }
 }
示例#3
0
 public function parseFile(\Phalcon\Annotations\Adapter $adapter, $className, $module)
 {
     $parser = new AnnotationParser($adapter->get($className));
     if ($parser->isExistsAnnotationClass(Service::CLASS_ANNOTATION)) {
         $this->listeners->add(new ModelListener($parser, $className));
     }
 }
示例#4
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;
 }
示例#5
0
 public function parseFile(Annotations $adapter, $className, $module)
 {
     $parser = new AnnotationParser($adapter->get($className));
     if ($parser->isExistsAnnotationClass(self::CLASS_ANNOTATION)) {
         $this->services->add(new ModelService($parser, $className, function ($className) {
             return $this->getServiceName($className);
         }, function ($value) {
             return $this->getValue($value);
         }));
     }
 }
示例#6
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;
 }
示例#7
0
 private function getProperties()
 {
     $result = "\t\t\t'properties' => [\n";
     $properties = [];
     foreach ($this->annotationParser->getProperties(PluginService::PROPERTY_ANNOTATION) as $field => $list) {
         $property = $this->getPropertyService($field, $list);
         if ($property != "") {
             $properties[] = sprintf("\t\t\t\t[\n%s\n\t\t\t\t]", $property);
         }
     }
     foreach ($this->annotationParser->getProperties(PluginService::PROPERTY_ANNOTATION_VALUE) as $field => $list) {
         $property = $this->getPropertyValue($field, $list);
         if ($property != "") {
             $properties[] = sprintf("\t\t\t\t[\n%s\n\t\t\t\t]", $property);
         }
     }
     $result .= implode(",\n", $properties);
     $result .= "\n\t\t\t]\n";
     return $result;
 }
示例#8
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;
 }