protected function RequestMethodInvocation($msg) { //invocation event handlers $rmi = new RequestMethodInvocation($msg); Log::writeInfo("Received RMI:" . $rmi, $target = 'file'); if (GlobalState::$TYPE == 'CLOUD' && time() * 1000 - $rmi->getTimestamp() > $this->timeout) { Log::writeError("RMI ignored by timeout" . $rmi, $target = 'file'); return; } if (GlobalState::$TYPE === 'CLOUD') { Config::$RELATIVE_PATH = $msg['relativePath']; Config::$TASK_APPLICATION_ID = $msg['applicationId']; ClassManager::analyze(PathBuilder::getClasses()); } $code_executor = $this->executor_holder->getCodeExecutor($rmi->getApplicationId(), $rmi->getAppVersionId(), true); $code_executor->invokeMethod($rmi); }
public static function load($argc, $argv) { Config::loadConfig(); self::phpEnviromentInit(); Log::init(GlobalState::$TYPE, Config::$CORE['logging_in_cloud_mode'], Config::$CORE['os_type']); Log::writeInfo("Start CodeRunner", $target = 'file'); EventDefinitionHolder::getInstance()->load(); if (GlobalState::$TYPE === 'LOCAL') { self::checkForInputKeys($argc, $argv); self::checkDefaultKeys(); ClassManager::analyze(PathBuilder::getClasses()); self::printGreeting(); } else { self::checkInputKeysForCloud($argc, $argv); } $code_runner = new CodeRunner(); $code_runner->loadMessageProcessor(); $code_runner->start(); }
public static function analyze() { Log::writeInfo("ClassManager start analyze classes", "file"); $all_files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(PathBuilder::getClasses())); $php_files = new RegexIterator($all_files, '/\\.php$/'); $classes_namespaces = []; foreach ($php_files as $php_file) { $class_info = []; //$class_info["parent_class"] = self::getParentClass( file_get_contents( $php_file->getRealPath() ) ); $class_info['namespace'] = str_replace("/", "\\", trim(dirname(substr($php_file->getRealPath(), strlen(PathBuilder::getClasses()))), "/")); $class_info['class_name'] = basename($php_file->getRealPath(), ".php"); $class_info['path'] = $php_file->getRealPath(); self::putToHolder($class_info); $classes_namespaces[$class_info['namespace']] = pathinfo($class_info["path"])["dirname"]; //key = namespace key = path to folder; Backendless::mapTableToClass($class_info['class_name'], $class_info['namespace'] . "\\" . $class_info['class_name']); // set mapping for SDK. } foreach ($classes_namespaces as $namespace => $path) { Autoload::addNamespace($namespace, $path); // add autoloading for user classes } Log::writeInfo("ClassManager finished analyze classes", "file"); }