seeddms-code/utils/console

88 lines
3.9 KiB
PHP
Executable File

#!/usr/bin/env php
<?php
ini_set('include_path', __DIR__.'/../' . PATH_SEPARATOR . ini_get('include_path'));
ini_set('include_path', __DIR__.'/../../' . PATH_SEPARATOR . ini_get('include_path'));
require 'vendor/autoload.php';
require_once('Log.php');
require_once('inc/inc.Utils.php');
use Symfony\Component\Console\Application;
use Seeddms\Console\Commands\StatsCommand;
use Seeddms\Console\Commands\AddfolderCommand;
use Seeddms\Console\Commands\AdddocumentCommand;
use Seeddms\Console\Commands\DeleteCommand;
use Seeddms\Console\Commands\ClearcacheCommand;
use Seeddms\Console\Commands\ListcacheCommand;
use Seeddms\Console\Commands\ListextensionCommand;
use Seeddms\Console\Commands\ConfigureextensionCommand;
use Seeddms\Console\Commands\UploadextensionCommand;
use Seeddms\Console\Commands\PackageextensionCommand;
use Seeddms\Console\Commands\ReloadextensionCommand;
use Seeddms\Console\Commands\CheckextensionCommand;
use Seeddms\Console\Commands\RepositoryextensionCommand;
use Seeddms\Console\Commands\UpdateextensionCommand;
use Seeddms\Console\Commands\DownloadextensionCommand;
use Seeddms\Seeddms\Settings;
use Seeddms\Seeddms\Translator;
/* Check if configuration is at regular place. Otherwise set
* SEEDDMS_CONFIG_FILE in your shell.
*/
if (file_exists(__DIR__.'/../../conf/settings.xml'))
$settings = new Settings(__DIR__.'/../../conf/settings.xml');
else
$settings = new Settings();
/* For now includce inc.Language.php, because it defines the old
* translation functions (e.g. getMLText()), which are still used
* by many extensions.
*/
require_once('inc/inc.Language.php');
//$translator = new Translator($settings);
//$translator->init();
$logger = getLogger($settings, 'console-');
require_once('inc/inc.Extension.php');
$application = new Application();
$application->add(new StatsCommand($settings, $logger, $translator));
$application->add(new AddfolderCommand($settings, $logger, $translator));
$application->add(new AdddocumentCommand($settings, $logger, $translator, $extmgr));
$application->add(new DeleteCommand($settings, $logger, $translator));
$application->add(new ClearcacheCommand($settings, $logger, $translator));
$application->add(new ListcacheCommand($settings, $logger, $translator));
$application->add(new ListextensionCommand($settings, $logger, $translator, $extmgr));
$application->add(new ConfigureextensionCommand($settings, $logger, $translator, $extmgr));
$application->add(new UploadextensionCommand($settings, $logger, $translator, $extmgr));
$application->add(new PackageextensionCommand($settings, $logger, $translator, $extmgr));
$application->add(new ReloadextensionCommand($settings, $logger, $translator, $extmgr));
$application->add(new CheckextensionCommand($settings, $logger, $translator, $extmgr));
$application->add(new RepositoryextensionCommand($settings, $logger, $translator, $extmgr));
$application->add(new UpdateextensionCommand($settings, $logger, $translator, $extmgr));
$application->add(new DownloadextensionCommand($settings, $logger, $translator, $extmgr));
/* If extension are not compatible with the current version of
* SeedDMS anymore, calling the hooks may fail and exit this
* script. Hence there no change to even disable an extension with
* `utils/console ext:configure --name <extname> --disable`
* In such a case the last resort is to set the environment variable
* SEEDDMS_NO_EXTENSION_HOOKS to any value, which will prevent calling
* any hooks.
*/
if (false === getenv('SEEDDMS_NO_EXTENSION_HOOKS')) {
if (isset($GLOBALS['SEEDDMS_HOOKS']['console'])) {
foreach ($GLOBALS['SEEDDMS_HOOKS']['console'] as $hookObj) {
if (method_exists($hookObj, 'addCommand')) {
$hookObj->addCommand($application, ['settings'=>$settings, 'logger'=>$logger, 'translator'=>$translator, 'extmgr'=>$extmgr]);
}
}
}
} else {
echo "NOT RUNNING HOOKS\n\n";
}
$application->run();
// vim: ts=4 sw=4 expandtab