mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Select storage depending on configuration
This commit is contained in:
parent
d7652658f2
commit
3a2548ed89
@ -11,6 +11,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\DocStoreBundle;
|
namespace Chill\DocStoreBundle;
|
||||||
|
|
||||||
|
use Chill\DocStoreBundle\DependencyInjection\Compiler\StorageConfigurationCompilerPass;
|
||||||
use Chill\DocStoreBundle\GenericDoc\GenericDocForAccompanyingPeriodProviderInterface;
|
use Chill\DocStoreBundle\GenericDoc\GenericDocForAccompanyingPeriodProviderInterface;
|
||||||
use Chill\DocStoreBundle\GenericDoc\GenericDocForPersonProviderInterface;
|
use Chill\DocStoreBundle\GenericDoc\GenericDocForPersonProviderInterface;
|
||||||
use Chill\DocStoreBundle\GenericDoc\Twig\GenericDocRendererInterface;
|
use Chill\DocStoreBundle\GenericDoc\Twig\GenericDocRendererInterface;
|
||||||
@ -27,5 +28,7 @@ class ChillDocStoreBundle extends Bundle
|
|||||||
->addTag('chill_doc_store.generic_doc_person_provider');
|
->addTag('chill_doc_store.generic_doc_person_provider');
|
||||||
$container->registerForAutoconfiguration(GenericDocRendererInterface::class)
|
$container->registerForAutoconfiguration(GenericDocRendererInterface::class)
|
||||||
->addTag('chill_doc_store.generic_doc_renderer');
|
->addTag('chill_doc_store.generic_doc_renderer');
|
||||||
|
|
||||||
|
$container->addCompilerPass(new StorageConfigurationCompilerPass());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ class ChillDocStoreExtension extends Extension implements PrependExtensionInterf
|
|||||||
$this->prependTwig($container);
|
$this->prependTwig($container);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function prependAuthorization(ContainerBuilder $container)
|
private function prependAuthorization(ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
$container->prependExtensionConfig('security', [
|
$container->prependExtensionConfig('security', [
|
||||||
'role_hierarchy' => [
|
'role_hierarchy' => [
|
||||||
@ -69,7 +69,7 @@ class ChillDocStoreExtension extends Extension implements PrependExtensionInterf
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function prependRoute(ContainerBuilder $container)
|
private function prependRoute(ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
// declare routes for task bundle
|
// declare routes for task bundle
|
||||||
$container->prependExtensionConfig('chill_main', [
|
$container->prependExtensionConfig('chill_main', [
|
||||||
@ -81,7 +81,7 @@ class ChillDocStoreExtension extends Extension implements PrependExtensionInterf
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function prependTwig(ContainerBuilder $container)
|
private function prependTwig(ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
$twigConfig = [
|
$twigConfig = [
|
||||||
'form_themes' => ['@ChillDocStore/Form/fields.html.twig'],
|
'form_themes' => ['@ChillDocStore/Form/fields.html.twig'],
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Chill\DocStoreBundle\DependencyInjection\Compiler;
|
||||||
|
|
||||||
|
use Chill\DocStoreBundle\AsyncUpload\Driver\LocalStorage\TempUrlLocalStorageGenerator;
|
||||||
|
use Chill\DocStoreBundle\AsyncUpload\Driver\OpenstackObjectStore\TempUrlOpenstackGenerator;
|
||||||
|
use Chill\DocStoreBundle\AsyncUpload\TempUrlGeneratorInterface;
|
||||||
|
use Chill\DocStoreBundle\Service\StoredObjectManagerInterface;
|
||||||
|
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||||
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
|
||||||
|
class StorageConfigurationCompilerPass implements CompilerPassInterface
|
||||||
|
{
|
||||||
|
private const SERVICES_OPENSTACK = [
|
||||||
|
\Chill\DocStoreBundle\AsyncUpload\Driver\OpenstackObjectStore\StoredObjectManager::class,
|
||||||
|
TempUrlOpenstackGenerator::class,
|
||||||
|
];
|
||||||
|
|
||||||
|
private const SERVICES_LOCAL_STORAGE = [
|
||||||
|
\Chill\DocStoreBundle\AsyncUpload\Driver\LocalStorage\StoredObjectManager::class,
|
||||||
|
TempUrlLocalStorageGenerator::class,
|
||||||
|
];
|
||||||
|
|
||||||
|
public function process(ContainerBuilder $container)
|
||||||
|
{
|
||||||
|
$config = $container
|
||||||
|
->getParameterBag()
|
||||||
|
->resolveValue($container->getParameter('chill_doc_store'));
|
||||||
|
|
||||||
|
if (array_key_exists('openstack', $config) && array_key_exists('local_storage', $config)) {
|
||||||
|
throw new InvalidConfigurationException('chill_doc_store: you can either configure a local storage (key local_storage) or openstack storage (key openstack). Choose between them.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('local_storage', $config)) {
|
||||||
|
foreach (self::SERVICES_OPENSTACK as $service) {
|
||||||
|
$container->removeDefinition($service);
|
||||||
|
}
|
||||||
|
|
||||||
|
$container->setAlias(StoredObjectManagerInterface::class, \Chill\DocStoreBundle\AsyncUpload\Driver\LocalStorage\StoredObjectManager::class);
|
||||||
|
$container->setAlias(TempUrlGeneratorInterface::class, TempUrlLocalStorageGenerator::class);
|
||||||
|
} else {
|
||||||
|
foreach (self::SERVICES_LOCAL_STORAGE as $service) {
|
||||||
|
$container->removeDefinition($service);
|
||||||
|
}
|
||||||
|
|
||||||
|
$container->setAlias(StoredObjectManagerInterface::class, \Chill\DocStoreBundle\AsyncUpload\Driver\OpenstackObjectStore\StoredObjectManager::class);
|
||||||
|
$container->setAlias(TempUrlGeneratorInterface::class, TempUrlOpenstackGenerator::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,6 @@ services:
|
|||||||
tags:
|
tags:
|
||||||
- { name: doctrine.repository_service }
|
- { name: doctrine.repository_service }
|
||||||
|
|
||||||
|
|
||||||
Chill\DocStoreBundle\Security\Authorization\:
|
Chill\DocStoreBundle\Security\Authorization\:
|
||||||
resource: "./../Security/Authorization"
|
resource: "./../Security/Authorization"
|
||||||
|
|
||||||
@ -56,6 +55,3 @@ services:
|
|||||||
|
|
||||||
Chill\DocStoreBundle\AsyncUpload\Command\:
|
Chill\DocStoreBundle\AsyncUpload\Command\:
|
||||||
resource: '../AsyncUpload/Command/'
|
resource: '../AsyncUpload/Command/'
|
||||||
|
|
||||||
Chill\DocStoreBundle\AsyncUpload\TempUrlGeneratorInterface:
|
|
||||||
alias: Chill\DocStoreBundle\AsyncUpload\Driver\OpenstackObjectStore\TempUrlOpenstackGenerator
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user