mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-25 02:43:11 +00:00
Add plugin capability to add routes.
This commit is contained in:
@@ -114,6 +114,7 @@ use Neutron\Silex\Provider\FilesystemServiceProvider;
|
||||
use Neutron\ReCaptcha\ReCaptchaServiceProvider;
|
||||
use PHPExiftool\PHPExiftoolServiceProvider;
|
||||
use Silex\Application as SilexApplication;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Silex\Provider\FormServiceProvider;
|
||||
use Silex\Provider\MonologServiceProvider;
|
||||
use Silex\Provider\SessionServiceProvider;
|
||||
@@ -833,6 +834,8 @@ class Application extends SilexApplication
|
||||
|
||||
$this->mount('/thesaurus', new Thesaurus());
|
||||
$this->mount('/xmlhttp', new ThesaurusXMLHttp());
|
||||
|
||||
$this->bindPluginRoutes('plugin.controller_providers.root');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -854,4 +857,36 @@ class Application extends SilexApplication
|
||||
{
|
||||
return static::$flashTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $routeParameter
|
||||
*/
|
||||
public function bindPluginRoutes($routeParameter)
|
||||
{
|
||||
foreach ($this[$routeParameter] as $provider) {
|
||||
$prefix = '';
|
||||
|
||||
if (is_array($provider)) {
|
||||
$providerDefinition = $provider;
|
||||
list($prefix, $provider) = $providerDefinition;
|
||||
}
|
||||
|
||||
if (!is_string($prefix) || !is_string($provider)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$prefix = '/' . ltrim($prefix, '/');
|
||||
if (!isset($this[$provider])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$provider = $this[$provider];
|
||||
|
||||
if (!$provider instanceof ControllerProviderInterface) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->mount($prefix, $provider);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,6 +129,7 @@ return call_user_func(function ($environment = PhraseaApplication::ENV_PROD) {
|
||||
$app->mount('/api/oauthv2', new Oauth2());
|
||||
$app->mount('/datafiles/', new Datafiles());
|
||||
$app->mount('/api/v1', new V1());
|
||||
$app->bindPluginRoutes('plugin.controller_providers.api');
|
||||
|
||||
$app['dispatcher']->addSubscriber(new ApiOauth2ErrorsSubscriber($app['phraseanet.exception_handler']));
|
||||
$app['dispatcher']->addSubscriber(new ApiCorsSubscriber($app));
|
||||
|
||||
@@ -23,6 +23,16 @@ class PluginServiceProvider implements ServiceProviderInterface
|
||||
});
|
||||
|
||||
$app['plugin.locale.textdomains'] = new \ArrayObject();
|
||||
|
||||
// Routes will be bound after all others
|
||||
// Add a new controller provider can be added as follows
|
||||
// $app['plugin.controller_providers'][] = array('/prefix', 'controller_provider_service_key');
|
||||
$app['plugin.controller_providers.root'] = new \ArrayObject();
|
||||
|
||||
// Routes will be bound after all others
|
||||
// Add a new controller provider can be added as follows
|
||||
// $app['plugin.controller_providers'][] = array('/prefix', 'controller_provider_service_key');
|
||||
$app['plugin.controller_providers.api'] = new \ArrayObject();
|
||||
}
|
||||
|
||||
public function boot(Application $app)
|
||||
|
||||
Reference in New Issue
Block a user