/** * (non-PHPdoc) * @see \oat\oatbox\action\Action::__invoke() */ public function __invoke($params) { $merged = array_merge(common_ext_ExtensionsManager::singleton()->getInstalledExtensions(), $this->getMissingExtensions()); $sorted = \helpers_ExtensionHelper::sortByDependencies($merged); $report = new common_report_Report(common_report_Report::TYPE_INFO, 'Running extension update'); foreach ($sorted as $ext) { try { if (!common_ext_ExtensionsManager::singleton()->isInstalled($ext->getId())) { $installer = new \tao_install_ExtensionInstaller($ext); $installer->install(); $report->add(new common_report_Report(common_report_Report::TYPE_SUCCESS, 'Installed ' . $ext->getName())); } else { $report->add($this->updateExtension($ext)); } } catch (common_ext_MissingExtensionException $ex) { $report->add(new common_report_Report(common_report_Report::TYPE_ERROR, $ex->getMessage())); break; } catch (common_ext_OutdatedVersionException $ex) { $report->add(new common_report_Report(common_report_Report::TYPE_ERROR, $ex->getMessage())); break; } catch (Exception $e) { $this->logError('Exception during update of ' . $ext->getId() . ': ' . get_class($e) . ' "' . $e->getMessage() . '"'); $report->setType(common_report_Report::TYPE_ERROR); $report->setTitle('Update failed'); $report->add(new common_report_Report(common_report_Report::TYPE_ERROR, 'Exception during update of ' . $ext->getId() . '.')); break; } } $this->logInfo(helpers_Report::renderToCommandline($report, false)); return $report; }
/** * Short description of method run * * @access public * @author Jerome Bogaerts, <*****@*****.**> * @return void */ public function run() { $userService = tao_models_classes_UserService::singleton(); $this->outVerbose("Connecting to TAO as '" . $this->options['user'] . "' ..."); if ($userService->loginUser($this->options['user'], $this->options['password'])) { $this->outVerbose("Connected to TAO as '" . $this->options['user'] . "'."); $filename = $this->options['input']; $action = new ImportRdf(); $params = array($filename); if (!empty($this->options['model'])) { $nameSpace = common_ext_NamespaceManager::singleton()->getNamespace($this->options['model']); $params[] = $nameSpace->getModelId(); } $report = $action->__invoke($params); $string = helpers_Report::renderToCommandline($report); foreach (explode(PHP_EOL, $string) as $line) { $this->out($line); } } else { $this->err("Unable to connect to TAO as '" . $this->options['user'] . "'.", true); } }
protected function dispatchCli() { $params = $_SERVER['argv']; $file = array_shift($params); if (count($params) < 1) { $report = new Report(Report::TYPE_ERROR, __('No action specified')); } else { $actionIdentifier = array_shift($params); $cliController = new CliController(); $report = $cliController->runAction($actionIdentifier, $params); } echo \helpers_Report::renderToCommandline($report); }
<?php /** * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; under version 2 * of the License (non-upgradable). * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Copyright (c) 2014 (original work) Open Assessment Technologies SA; * * */ require_once dirname(__FILE__) . '/../includes/raw_start.php'; use oat\tao\model\extension\UpdateExtensions; use oat\oatbox\service\ServiceManager; $action = new UpdateExtensions(); $action->setServiceLocator(ServiceManager::getServiceManager()); $report = $action->__invoke(array()); echo helpers_Report::renderToCommandline($report); echo 'Update completed' . PHP_EOL;
/** * Contains the logic to render a report and its children to the command line * * @deprecated * @param common_report_Report $report A report to be rendered. * @param integer $intend the intend of the message. * @return string The command line output of $report. */ public static function renderToCommandline(common_report_Report $report, $intend = 0) { return helpers_Report::renderToCommandLine($report, helpers_Report::AUTOSENSE, $intend); }