mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 06:53:15 +00:00
fix AddPluginTest
This commit is contained in:
@@ -15,6 +15,21 @@ use Alchemy\Phrasea\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
function normalizePath($path) {
|
||||
return array_reduce(explode('/', $path), function ($a, $b) {
|
||||
if($a === 0)
|
||||
$a = '/';
|
||||
|
||||
if($b === '' || $b === '.')
|
||||
return $a;
|
||||
|
||||
if($b === '..')
|
||||
return dirname($a);
|
||||
|
||||
return preg_replace('/\/+/', '/', "$a/$b");
|
||||
}, 0);
|
||||
}
|
||||
|
||||
abstract class AbstractPluginCommand extends Command
|
||||
{
|
||||
protected function validatePlugins(InputInterface $input, OutputInterface $output)
|
||||
@@ -54,13 +69,12 @@ abstract class AbstractPluginCommand extends Command
|
||||
|
||||
protected function doInstallPlugin($source, InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
|
||||
$output->write("Validating plugin...");
|
||||
$manifest = $this->container['plugins.plugins-validator']->validatePlugin($source);
|
||||
$output->writeln(" <comment>OK</comment> found <info>".$manifest->getName()."</info>");
|
||||
|
||||
$targetDir = $this->container['plugin.path'] . DIRECTORY_SEPARATOR . $manifest->getName();
|
||||
if (realpath($targetDir) !== realpath($source)) {
|
||||
if (normalizePath($targetDir) !== normalizePath($source)) {
|
||||
$temporaryDir = $this->container['temporary-filesystem']->createTemporaryDirectory();
|
||||
$output->write("Importing <info>$source</info>...");
|
||||
$this->container['plugins.importer']->import($source, $temporaryDir);
|
||||
|
Reference in New Issue
Block a user