Beispiel #1
0
 /**
  * @param string $propertyName
  * @param Collection $annotations
  */
 private function setPropertyService($propertyName, Collection $annotations)
 {
     if ($annotations->has(Service::PROPERTY_ANNOTATION)) {
         $annProperty = $annotations->get(Service::PROPERTY_ANNOTATION);
         if (!is_null($serviceName)) {
             $this->{$propertyName} = $this->getDI()->get($serviceName);
         } else {
             Logger::getInstance()->warning("Annotation Inject in Controller required attribute service");
         }
     }
 }
Beispiel #2
0
 /**
  * @return bool
  */
 public function isChangeConfiguration()
 {
     $result = true;
     if (file_exists($this->getFileLog())) {
         $result = $this->isChangedFiles();
     }
     if ($result) {
         $this->saveCache($this->createNewCache());
     }
     Logger::getInstance()->debug("checked file changes");
     return $result;
 }
Beispiel #3
0
 public function buildRoute(Annotation $annotation, $method)
 {
     $path = $annotation->getArgument('path');
     $result = [];
     if ($path) {
         $result['action'] = $this->getActionName($method);
         $result['path'] = $path;
         $result['method'] = $annotation->getArgument('method');
     } else {
         Logger::getInstance()->warning("Annotation Route must have attribute path @Route(path=/uri)");
     }
     return $result;
 }
Beispiel #4
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;
 }
Beispiel #5
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;
 }
Beispiel #6
0
 protected function loadServices($di)
 {
     $this->registerService->setDependencyInjection($di)->setProjectPath($this->projectPath)->setModules($this->modules)->setEnvironment($this->environment)->setModulesPath($this->getModulesPath());
     $this->app->getContainer()->registerServices($this->registerService);
     Logger::getInstance()->debug("Loaded services");
 }
Beispiel #7
0
 private function getPropertyValue($field, ArrayList $list)
 {
     $property = $list->find(function (Annotation $annotation) {
         return $annotation->getName() == PluginService::PROPERTY_ANNOTATION_VALUE;
     });
     $valueName = $property->getArgument(0);
     if (!is_null($valueName)) {
         $definition = sprintf("\t\t\t\t\t'name' => '%s',\n", $field);
         $pattern = "\t\t\t\t\t'value' => ['type' => 'parameter', 'value' => '%s']";
         $c = $this->getParameterValue;
         return $definition . sprintf($pattern, $c($valueName));
     }
     Logger::getInstance()->warning("Annotation Value required name");
     return "";
 }