/** * @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"); } } }
/** * @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; }
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; }
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; }
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; }
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"); }
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 ""; }