mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
fix folder name
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\ThirdPartyBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
use Symfony\Component\DependencyInjection\Loader;
|
||||
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
||||
use Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter;
|
||||
|
||||
/**
|
||||
* This is the class that loads and manages your bundle configuration.
|
||||
*
|
||||
* @link http://symfony.com/doc/current/cookbook/bundles/extension.html
|
||||
*/
|
||||
class ChillThirdPartyExtension extends Extension implements PrependExtensionInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
$configuration = new Configuration();
|
||||
$config = $this->processConfiguration($configuration, $configs);
|
||||
|
||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config'));
|
||||
$loader->load('services.yaml');
|
||||
$loader->load('services/controller.yaml');
|
||||
$loader->load('services/form.yaml');
|
||||
$loader->load('services/security.yaml');
|
||||
$loader->load('services/3partytype.yaml');
|
||||
$loader->load('services/search.yaml');
|
||||
$loader->load('services/templating.yaml');
|
||||
$loader->load('services/menu.yaml');
|
||||
}
|
||||
|
||||
public function prepend(ContainerBuilder $container)
|
||||
{
|
||||
$this->preprendRoutes($container);
|
||||
$this->prependRoleHierarchy($container);
|
||||
}
|
||||
|
||||
protected function preprendRoutes(ContainerBuilder $container)
|
||||
{
|
||||
//declare routes for 3party bundle
|
||||
$container->prependExtensionConfig('chill_main', array(
|
||||
'routing' => array(
|
||||
'resources' => array(
|
||||
'@ChillThirdPartyBundle/config/routes.yaml'
|
||||
)
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
protected function prependRoleHierarchy(ContainerBuilder $container)
|
||||
{
|
||||
$container->prependExtensionConfig('security', array(
|
||||
'role_hierarchy' => array(
|
||||
ThirdPartyVoter::CREATE => [ThirdPartyVoter::SHOW],
|
||||
ThirdPartyVoter::UPDATE => [ThirdPartyVoter::SHOW],
|
||||
)
|
||||
));
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\ThirdPartyBundle\DependencyInjection\CompilerPass;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Chill\ThirdPartyBundle\ThirdPartyType\ThirdPartyTypeManager;
|
||||
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* Load services tagged chill_3party.provider and add them to the service
|
||||
* definition of manager
|
||||
*
|
||||
*/
|
||||
class ThirdPartyTypeCompilerPass implements CompilerPassInterface
|
||||
{
|
||||
const TAG = 'chill_3party.provider';
|
||||
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
$definition = $container->getDefinition(ThirdPartyTypeManager::class);
|
||||
$usedKeys = [];
|
||||
|
||||
foreach ($container->findTaggedServiceIds(self::TAG) as $id => $tags) {
|
||||
$taggedService = $container->getDefinition($id);
|
||||
// check forr keys already in use :
|
||||
$key = $taggedService->getClass()::getKey();
|
||||
if (\in_array($key, $usedKeys)) {
|
||||
throw new \LogicException(sprintf("Tag with key \"%s\" is already in used",
|
||||
$key));
|
||||
}
|
||||
$usedKeys[] = $key;
|
||||
// alter the service definition of manager
|
||||
$definition->addMethodCall('addProvider', [ new Reference($id) ]);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\ThirdPartyBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
|
||||
/**
|
||||
* This is the class that validates and merges configuration from your app/config files.
|
||||
*
|
||||
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/configuration.html}
|
||||
*/
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConfigTreeBuilder()
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('chill_third_party');
|
||||
$rootNode = $treeBuilder->getRootNode('chill_third_party');
|
||||
|
||||
// Here you should define the parameters that are allowed to
|
||||
// configure your bundle. See the documentation linked above for
|
||||
// more information on that topic.
|
||||
|
||||
return $treeBuilder;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user