private function processAnalyze($provider_name, $provider_data, $class, $event_handlers_model) { Log::writeInfo("Processing analyzing class: " . $class['class_name'], $target = 'file'); //ReflectionUtil::includeFile( $class['path'] ); //ClassManager::addAsIncluded( $class['path'] ); $reflection = new ReflectionClass("\\" . $class['namespace'] . "\\" . $class['class_name']); $methods = $reflection->getMethods(ReflectionMethod::IS_PUBLIC); $target = $this->getTarget($class); $timer_definition = self::$event_definition_holder->getDefinitionByName("TIMER", 'execute'); $timer_id = $timer_definition['id']; $custom_handler_definition = self::$event_definition_holder->getDefinitionByName("CUSTOM", 'handleEvent'); $custom_handler_id = $custom_handler_definition['id']; foreach ($methods as $method) { $definition = self::$event_definition_holder->getDefinitionByName($provider_name, $method->name); if ($definition == null) { continue; } $handler = new EventHandler(); $handler->setId($definition['id']); $handler->setTarget($target); $handler->setAsync($this->getAsync($method->name, $class)); $handler->setTimer($definition['id'] == $timer_id ? true : false); $handler->setProvider('\\' . $class['namespace'] . '\\' . $class['class_name']); if ($handler->isTimer()) { $handler->setTarget($this->getTimer($class)); $handler->setAsync(true); if (!$this->isValidTimer($handler)) { continue; } } if ($handler->getId() == $custom_handler_id) { $handler->setTarget($this->getCustomEventName($class)); if ($handler->getTarget() == null) { throw new CodeRunnerException("Asset is not present for custom event handler: " . $class['class_name']); } } if (Config::$CORE['provider'][$provider_name]['asset'] && $handler->getTarget() == null) { throw new CodeRunnerException("Asset is not present for handler: " . $class['class_name']); } $event_handlers_model->addHandler($handler); } }
public function loadFromJson($path) { if (file_exists($path)) { $data_array = json_decode(file_get_contents($path), true); $this->application_id = $data_array['applicationId']; $this->app_version_id = $data_array['appVersionId']; foreach ($data_array["handlers"] as $handler_item) { $handler = new EventHandler(); $handler->setId($handler_item['id']); $handler->setAsync($handler_item['async']); $handler->setTarget($handler_item['target']); $handler->setTimer($handler_item['timer']); $handler->setProvider($handler_item['provider']); $this->addHandler($handler); } } else { throw new Exception("Event handler model json file absent in path: {$path}"); } }