mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 02:23:51 +00:00
Initialize a CRUD for entities
This commit is contained in:
@@ -32,6 +32,8 @@ use Chill\MainBundle\Doctrine\DQL\JsonAggregate;
|
||||
use Chill\MainBundle\Doctrine\DQL\JsonbExistsInArray;
|
||||
use Chill\MainBundle\Doctrine\DQL\Similarity;
|
||||
use Chill\MainBundle\Doctrine\DQL\OverlapsI;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* This class load config for chillMainExtension.
|
||||
@@ -96,6 +98,8 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
||||
array('homepage' => $config['widgets']['homepage']):
|
||||
array()
|
||||
);
|
||||
|
||||
$this->configureCruds($container, $config['cruds']);
|
||||
|
||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
$loader->load('services.yml');
|
||||
@@ -117,6 +121,7 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
||||
$loader->load('services/phonenumber.yml');
|
||||
$loader->load('services/cache.yml');
|
||||
$loader->load('services/templating.yml');
|
||||
$loader->load('services/crud.yml');
|
||||
}
|
||||
|
||||
public function getConfiguration(array $config, ContainerBuilder $container)
|
||||
@@ -194,4 +199,27 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
||||
'channels' => array('chill')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ContainerBuilder $container
|
||||
* @param array $config the config under 'cruds' key
|
||||
* @return null
|
||||
*/
|
||||
protected function configureCruds(ContainerBuilder $container, $config)
|
||||
{
|
||||
if (count($config) === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$container->setParameter('chill_main_crud_route_loader_config', $config);
|
||||
|
||||
$definition = new Definition();
|
||||
$definition
|
||||
->setClass(\Chill\MainBundle\CRUD\Routing\CRUDRoutesLoader::class)
|
||||
->addArgument('%chill_main_crud_route_loader_config%')
|
||||
;
|
||||
|
||||
$container->setDefinition('chill_main_crud_route_loader', $definition);
|
||||
}
|
||||
}
|
||||
|
@@ -116,6 +116,23 @@ class Configuration implements ConfigurationInterface
|
||||
->append($this->addWidgetsConfiguration('homepage', $this->containerBuilder))
|
||||
->end() // end of widgets/children
|
||||
->end() // end of widgets
|
||||
->arrayNode('cruds')
|
||||
->defaultValue([])
|
||||
->arrayPrototype()
|
||||
->children()
|
||||
->scalarNode('class')->cannotBeEmpty()->isRequired()->end()
|
||||
->scalarNode('controller')->cannotBeEmpty()->isRequired()->end()
|
||||
->scalarNode('name')->cannotBeEmpty()->isRequired()->end()
|
||||
->scalarNode('base_path')->cannotBeEmpty()->isRequired()->end()
|
||||
->arrayNode('actions')
|
||||
->scalarPrototype()->end()
|
||||
//->defaultValue(['index', 'new', 'edit', 'show', 'delete'])
|
||||
//->ifEmpty()->thenInvalid()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
|
||||
->end()
|
||||
->end() // end of root/children
|
||||
->end() // end of root
|
||||
;
|
||||
|
Reference in New Issue
Block a user