mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 12:33:26 +00:00
Add public folder for plugins
This commit is contained in:
@@ -50,6 +50,13 @@ class AddPlugin extends AbstractPluginCommand
|
|||||||
$this->container['filesystem']->mirror($temporaryDir, $targetDir);
|
$this->container['filesystem']->mirror($temporaryDir, $targetDir);
|
||||||
$output->writeln(" <comment>OK</comment>");
|
$output->writeln(" <comment>OK</comment>");
|
||||||
|
|
||||||
|
$output->write("Copying public files <info>".$manifest->getName()."</info>...");
|
||||||
|
$this->container['filesystem']->mirror(
|
||||||
|
$targetDir . DIRECTORY_SEPARATOR . 'public',
|
||||||
|
$this->container['root.path'] . DIRECTORY_SEPARATOR . 'www' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $manifest->getName()
|
||||||
|
);
|
||||||
|
$output->writeln(" <comment>OK</comment>");
|
||||||
|
|
||||||
$output->write("Removing temporary directory...");
|
$output->write("Removing temporary directory...");
|
||||||
$this->container['filesystem']->remove($temporaryDir);
|
$this->container['filesystem']->remove($temporaryDir);
|
||||||
$output->writeln(" <comment>OK</comment>");
|
$output->writeln(" <comment>OK</comment>");
|
||||||
|
@@ -29,6 +29,7 @@ class PluginValidator
|
|||||||
{
|
{
|
||||||
$this->ensureComposer($directory);
|
$this->ensureComposer($directory);
|
||||||
$this->ensureManifest($directory);
|
$this->ensureManifest($directory);
|
||||||
|
$this->ensureDir($directory . DIRECTORY_SEPARATOR . 'public');
|
||||||
|
|
||||||
$manifest = $directory . DIRECTORY_SEPARATOR . 'manifest.json';
|
$manifest = $directory . DIRECTORY_SEPARATOR . 'manifest.json';
|
||||||
$data = @json_decode(@file_get_contents($manifest));
|
$data = @json_decode(@file_get_contents($manifest));
|
||||||
@@ -58,6 +59,13 @@ class PluginValidator
|
|||||||
$this->ensureFile($composer);
|
$this->ensureFile($composer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function ensureDir($dir)
|
||||||
|
{
|
||||||
|
if (!file_exists($dir) || !is_dir($dir) || !is_readable($dir)) {
|
||||||
|
throw new PluginValidationException(sprintf('Missing mandatory directory %s', $dir));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function ensureFile($file)
|
private function ensureFile($file)
|
||||||
{
|
{
|
||||||
if (!file_exists($file) || !is_file($file) || !is_readable($file)) {
|
if (!file_exists($file) || !is_file($file) || !is_readable($file)) {
|
||||||
|
@@ -62,6 +62,10 @@ class AddPluginTest extends PluginCommandTestCase
|
|||||||
->with('tempdir', self::$DI['app']['plugins.directory'].'/TestPlugin');
|
->with('tempdir', self::$DI['app']['plugins.directory'].'/TestPlugin');
|
||||||
|
|
||||||
self::$DI['app']['filesystem']->expects($this->at(1))
|
self::$DI['app']['filesystem']->expects($this->at(1))
|
||||||
|
->method('mirror')
|
||||||
|
->with(self::$DI['app']['plugins.directory'].'/TestPlugin/public', self::$DI['app']['root.path'].'/www/plugins/TestPlugin');
|
||||||
|
|
||||||
|
self::$DI['app']['filesystem']->expects($this->at(2))
|
||||||
->method('remove')
|
->method('remove')
|
||||||
->with('tempdir');
|
->with('tempdir');
|
||||||
|
|
||||||
|
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"name" : "test/test",
|
||||||
|
"description" : "test file",
|
||||||
|
"license" : "MIT",
|
||||||
|
"autoload": {
|
||||||
|
"psr-0": {
|
||||||
|
"Vendor" : "src"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"name": "TestPlugin",
|
||||||
|
"description" : "A custom class connector",
|
||||||
|
"keywords" : ["connector"],
|
||||||
|
"authors" : [
|
||||||
|
{
|
||||||
|
"name" : "Author name",
|
||||||
|
"homepage" : "http://example.com",
|
||||||
|
"email" : "email@example.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"homepage" : "http://example.com/project/example",
|
||||||
|
"license" : "MIT",
|
||||||
|
"version" : "0.1",
|
||||||
|
"minimum-phraseanet-version": "3.8",
|
||||||
|
"maximum-phraseanet-version": "3.9",
|
||||||
|
"services" : [
|
||||||
|
{
|
||||||
|
"class": "Vendor\\PluginService"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"extra" : {
|
||||||
|
"property" : "value"
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Vendor;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Application as PhraseaApplication;
|
||||||
|
use Silex\Application;
|
||||||
|
use Alchemy\Phrasea\Plugin\PluginProviderInterface;
|
||||||
|
|
||||||
|
class PluginService implements PluginProviderInterface
|
||||||
|
{
|
||||||
|
public function register(Application $app)
|
||||||
|
{
|
||||||
|
$app['plugin-test'] = 'hello world';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function boot(Application $app)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function create(PhraseaApplication $app)
|
||||||
|
{
|
||||||
|
return new static();
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user