コード例 #1
0
 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);
     }
 }