mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-07 01:54:27 +00:00
Add plugins reset command
This commit is contained in:
@@ -100,9 +100,7 @@ try {
|
||||
$cli->command(new XSendFileConfigurationDumper());
|
||||
$cli->command(new XSendFileMappingGenerator());
|
||||
|
||||
call_user_func(function ($cli) {
|
||||
require $cli['plugins.directory'] . '/commands.php';
|
||||
}, $cli);
|
||||
$cli->loadPlugins();
|
||||
|
||||
$result_code = is_int($cli->run()) ? : 1;
|
||||
} catch (\Exception $e) {
|
||||
|
@@ -19,6 +19,7 @@ namespace KonsoleKommander;
|
||||
use Alchemy\Phrasea\Core\Version;
|
||||
use Alchemy\Phrasea\Command\UpgradeDBDatas;
|
||||
use Alchemy\Phrasea\Command\Setup\Install;
|
||||
use Alchemy\Phrasea\Command\Setup\PluginsReset;
|
||||
use Alchemy\Phrasea\CLI;
|
||||
use Alchemy\Phrasea\Command\Setup\CheckEnvironment;
|
||||
|
||||
@@ -60,6 +61,7 @@ try {
|
||||
$app->command(new UpgradeDBDatas('system:upgrade-datas'));
|
||||
}
|
||||
|
||||
$app->command(new PluginsReset());
|
||||
$app->command(new CheckEnvironment('check:system'));
|
||||
$app->command(new Install('system:install'));
|
||||
|
||||
|
@@ -412,9 +412,21 @@ class Application extends SilexApplication
|
||||
$guesser->register(new VideoMimeTypeGuesser());
|
||||
|
||||
$app['plugins.directory'] = $app->share(function () {
|
||||
return realpath(__DIR__ . '/../../../plugins');
|
||||
});
|
||||
$dir = __DIR__ . '/../../../plugins';
|
||||
|
||||
if (is_dir($dir)) {
|
||||
return realpath($dir);
|
||||
} else {
|
||||
return $dir;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads Phraseanet plugins
|
||||
*/
|
||||
public function loadPlugins()
|
||||
{
|
||||
call_user_func(function ($app) {
|
||||
require $app['plugins.directory'] . '/services.php';
|
||||
}, $this);
|
||||
|
@@ -25,6 +25,7 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
return call_user_func(function($environment = PhraseaApplication::ENV_PROD) {
|
||||
|
||||
$app = new PhraseaApplication($environment);
|
||||
$app->loadPlugins();
|
||||
|
||||
$app['exception_handler'] = $app->share(function ($app) {
|
||||
return new ApiExceptionHandlerSubscriber($app);
|
||||
|
@@ -23,6 +23,7 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
return call_user_func(function($environment = PhraseaApplication::ENV_PROD) {
|
||||
|
||||
$app = new PhraseaApplication($environment);
|
||||
$app->loadPlugins();
|
||||
|
||||
$app['exception_handler'] = $app->share(function ($app) {
|
||||
return new PhraseaExceptionHandlerSubscriber($app['phraseanet.exception_handler']);
|
||||
|
@@ -90,4 +90,16 @@ class CLI extends Application
|
||||
$command->setContainer($this);
|
||||
$this['console']->add($command);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function loadPlugins()
|
||||
{
|
||||
parent::loadPlugins();
|
||||
|
||||
call_user_func(function ($cli) {
|
||||
require $cli['plugins.directory'] . '/commands.php';
|
||||
}, $this);
|
||||
}
|
||||
}
|
||||
|
34
lib/Alchemy/Phrasea/Command/Setup/PluginsReset.php
Normal file
34
lib/Alchemy/Phrasea/Command/Setup/PluginsReset.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Command\Setup;
|
||||
|
||||
use Alchemy\Phrasea\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class PluginsReset extends Command
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('plugins:reset');
|
||||
|
||||
$this->setDescription('Reset plugins in case a failure occured');
|
||||
}
|
||||
|
||||
protected function doExecute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->container['filesystem']->remove($this->container['plugins.directory']);
|
||||
$this->container['filesystem']->mirror(__DIR__ . '/../../../../conf.d/plugins', $this->container['plugins.directory']);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
0
lib/conf.d/plugins/account.less
Normal file
0
lib/conf.d/plugins/account.less
Normal file
10
lib/conf.d/plugins/autoload.php
Normal file
10
lib/conf.d/plugins/autoload.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
// This file is automatically generated, please do not edit it.
|
||||
// To update configuration, use bin/console plugins:* commands.
|
||||
|
||||
return call_user_func(function () {
|
||||
$loader = require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
return $loader;
|
||||
});
|
11
lib/conf.d/plugins/commands.php
Normal file
11
lib/conf.d/plugins/commands.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
// This file is automatically generated, please do not edit it.
|
||||
// To update configuration, use bin/console plugins:* commands.
|
||||
|
||||
use Alchemy\Phrasea\CLI;
|
||||
|
||||
return call_user_func(function (CLI $cli) {
|
||||
|
||||
return $cli;
|
||||
}, $cli);
|
0
lib/conf.d/plugins/login.less
Normal file
0
lib/conf.d/plugins/login.less
Normal file
11
lib/conf.d/plugins/services.php
Normal file
11
lib/conf.d/plugins/services.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
// This file is automatically generated, please do not edit it.
|
||||
// To update configuration, use bin/console plugins:* commands.
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
|
||||
return call_user_func(function (Application $app) {
|
||||
|
||||
return $app;
|
||||
}, $app);
|
7
lib/conf.d/plugins/twig-paths.php
Normal file
7
lib/conf.d/plugins/twig-paths.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
// This file is automatically generated, please do not edit it.
|
||||
// To update configuration, use bin/console plugins:* commands.
|
||||
|
||||
return array(
|
||||
);
|
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Alchemy\Tests\Phrasea\Command\Setup;
|
||||
|
||||
use Alchemy\Phrasea\Command\Setup\PluginsReset;
|
||||
|
||||
class PluginResetTest extends \PhraseanetPHPUnitAbstract
|
||||
{
|
||||
public function testRun()
|
||||
{
|
||||
$input = $this->getMock('Symfony\Component\Console\Input\InputInterface');
|
||||
$output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
|
||||
|
||||
$command = new PluginsReset();
|
||||
$command->setContainer(self::$DI['cli']);
|
||||
|
||||
$capturedSource = null;
|
||||
|
||||
self::$DI['cli']['filesystem'] = $this->getMockBuilder('Symfony\Component\Filesystem\Filesystem')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
self::$DI['cli']['filesystem']->expects($this->once())
|
||||
->method('remove')
|
||||
->with(self::$DI['cli']['plugins.directory']);
|
||||
self::$DI['cli']['filesystem']->expects($this->once())
|
||||
->method('mirror')
|
||||
->with($this->isType('string'), self::$DI['cli']['plugins.directory'])
|
||||
->will($this->returnCallback(function ($source, $target) use (&$capturedSource) {
|
||||
$capturedSource = $source;
|
||||
}));
|
||||
|
||||
$this->assertEquals(0, $command->execute($input, $output));
|
||||
$this->assertNotNull($capturedSource);
|
||||
$this->assertEquals(realpath(__DIR__ . '/../../../../../../lib/conf.d/plugins'), realpath($capturedSource));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user