public function preload_configure() { //check PHP version if (version_compare(preg_replace('/[^0-9.]/', '', PHP_VERSION), '5.1.3', '<')) { echo 'You need at least PHP 5.1.3 to run PrestaShop. Your current PHP version is ' . PHP_VERSION; exit(1); } $this->pluginDirs[] = PS_CLI_ROOT . '/plugins'; $arguments = PS_CLI_Arguments::getInstance(); // preconfiguration done. Load the plugins $this->read_plugin_directories(); $arguments->parse_arguments(); $this->allowRoot = $arguments->getOpt('allow-root', false); //check if running as root here; remove from ps-cli.php if ($path = $arguments->getOpt('path', false)) { $this->psPath = $path; } else { $this->psPath = self::find_ps_root(); if (!$this->psPath) { exit(1); } } //check if we can find backoffice dir from paPath $this->boPath = $this->find_backoffice_dir(); if (!$this->boPath) { exit(1); } if ($arguments->getOpt('porcelain', false)) { $this->porcelain = true; } if ($arguments->getOpt('verbose', false)) { $this->verbose = true; } $this->pluginDirs[] = PS_CLI_ROOT . '/plugins'; }
public static function callHooks($event) { echo "callHook called\n"; $arguments = PS_CLI_Arguments::getInstance(); $command = $arguments->get_command_handler_class(); if (isset(self::$_hooks[$event])) { foreach (self::$_hooks[$event] as $hook) { if (is_callable($hook[0])) { //todo: try//catch ? call_user_func_array($hook[0], $hook[1]); } else { echo '[DEBUG]: uncallable hook in event ' . $event; } } } else { echo "[DEBUG]: no hooks registered for event {$event} under command {$command}\n"; } }