mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
serializer on accompanying course
Two new routes: * `GET /{_locale}/person/api/1.0/accompanying-course/{parcours_id}/show.json`: get a json representation for a course * `POST /{_locale}/person/api/1.0/accompanying-course/{parcours_id}/participation.json`: add a particitipation to course. Usage: `curl -v --cookie "PHPSESSID=fed98aa23e40cb36e630f84155aea3bb;" -X POST --data '{ "id": 481 }' http://localhost:8001/fr/person/api/1.0/accompanying-course/270/participation.json` Will add the person with id "481" to the course.
This commit is contained in:
@@ -47,11 +47,11 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
||||
{
|
||||
/**
|
||||
* widget factory
|
||||
*
|
||||
*
|
||||
* @var WidgetFactoryInterface[]
|
||||
*/
|
||||
protected $widgetFactories = array();
|
||||
|
||||
|
||||
/**
|
||||
* @param WidgetFactoryInterface $factory
|
||||
*/
|
||||
@@ -59,7 +59,7 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
||||
{
|
||||
$this->widgetFactories[] = $factory;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return WidgetFactoryInterface[]
|
||||
*/
|
||||
@@ -67,7 +67,7 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
||||
{
|
||||
return $this->widgetFactories;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @param array $configs
|
||||
@@ -79,31 +79,31 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
||||
// configuration for main bundle
|
||||
$configuration = $this->getConfiguration($configs, $container);
|
||||
$config = $this->processConfiguration($configuration, $configs);
|
||||
|
||||
|
||||
$container->setParameter('chill_main.installation_name',
|
||||
$config['installation_name']);
|
||||
|
||||
$container->setParameter('chill_main.available_languages',
|
||||
$config['available_languages']);
|
||||
|
||||
$container->setParameter('chill_main.routing.resources',
|
||||
$config['routing']['resources']);
|
||||
|
||||
|
||||
$container->setParameter('chill_main.routing.resources',
|
||||
$config['routing']['resources']);
|
||||
|
||||
$container->setParameter('chill_main.pagination.item_per_page',
|
||||
$config['pagination']['item_per_page']);
|
||||
|
||||
$container->setParameter('chill_main.notifications',
|
||||
|
||||
$container->setParameter('chill_main.notifications',
|
||||
$config['notifications']);
|
||||
|
||||
$container->setParameter('chill_main.redis',
|
||||
|
||||
$container->setParameter('chill_main.redis',
|
||||
$config['redis']);
|
||||
|
||||
$container->setParameter('chill_main.phone_helper',
|
||||
|
||||
$container->setParameter('chill_main.phone_helper',
|
||||
$config['phone_helper'] ?? []);
|
||||
|
||||
|
||||
// add the key 'widget' without the key 'enable'
|
||||
$container->setParameter('chill_main.widgets',
|
||||
isset($config['widgets']['homepage']) ?
|
||||
$container->setParameter('chill_main.widgets',
|
||||
isset($config['widgets']['homepage']) ?
|
||||
array('homepage' => $config['widgets']['homepage']):
|
||||
array()
|
||||
);
|
||||
@@ -131,10 +131,11 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
||||
$loader->load('services/templating.yaml');
|
||||
$loader->load('services/timeline.yaml');
|
||||
$loader->load('services/search.yaml');
|
||||
|
||||
$loader->load('services/serializer.yaml');
|
||||
|
||||
$this->configureCruds($container, $config['cruds'], $loader);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $config
|
||||
* @param ContainerBuilder $container
|
||||
@@ -144,11 +145,11 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
||||
{
|
||||
return new Configuration($this->widgetFactories, $container);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ContainerBuilder $container
|
||||
*/
|
||||
public function prepend(ContainerBuilder $container)
|
||||
public function prepend(ContainerBuilder $container)
|
||||
{
|
||||
//add installation_name and date_format to globals
|
||||
$chillMainConfig = $container->getExtensionConfig($this->getAlias());
|
||||
@@ -163,7 +164,7 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
||||
'form_themes' => array('@ChillMain/Form/fields.html.twig')
|
||||
);
|
||||
$container->prependExtensionConfig('twig', $twigConfig);
|
||||
|
||||
|
||||
//add DQL function to ORM (default entity_manager)
|
||||
$container->prependExtensionConfig('doctrine', array(
|
||||
'orm' => array(
|
||||
@@ -182,7 +183,7 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
||||
)
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
//add dbal types (default entity_manager)
|
||||
$container->prependExtensionConfig('doctrine', array(
|
||||
'dbal' => [
|
||||
@@ -191,23 +192,23 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
||||
]
|
||||
]
|
||||
));
|
||||
|
||||
|
||||
//add current route to chill main
|
||||
$container->prependExtensionConfig('chill_main', array(
|
||||
'routing' => array(
|
||||
'resources' => array(
|
||||
'@ChillMainBundle/config/routes.yaml'
|
||||
)
|
||||
|
||||
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
//add a channel to log app events
|
||||
$container->prependExtensionConfig('monolog', array(
|
||||
'channels' => array('chill')
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ContainerBuilder $container
|
||||
* @param array $config the config under 'cruds' key
|
||||
@@ -218,31 +219,31 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
||||
if (count($config) === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$loader->load('services/crud.yaml');
|
||||
|
||||
|
||||
$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);
|
||||
|
||||
|
||||
$alreadyExistingNames = [];
|
||||
|
||||
|
||||
foreach ($config as $crudEntry) {
|
||||
$controller = $crudEntry['controller'];
|
||||
$controllerServiceName = 'cscrud_'.$crudEntry['name'].'_controller';
|
||||
$name = $crudEntry['name'];
|
||||
|
||||
|
||||
// check for existing crud names
|
||||
if (\in_array($name, $alreadyExistingNames)) {
|
||||
throw new LogicException(sprintf("the name %s is defined twice in CRUD", $name));
|
||||
}
|
||||
|
||||
|
||||
if (!$container->has($controllerServiceName)) {
|
||||
$controllerDefinition = new Definition($controller);
|
||||
$controllerDefinition->addTag('controller.service_arguments');
|
||||
@@ -250,7 +251,7 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
||||
$controllerDefinition->setClass($crudEntry['controller']);
|
||||
$container->setDefinition($controllerServiceName, $controllerDefinition);
|
||||
}
|
||||
|
||||
|
||||
$container->setParameter('chill_main_crud_config_'.$name, $crudEntry);
|
||||
$container->getDefinition($controllerServiceName)
|
||||
->addMethodCall('setCrudConfig', ['%chill_main_crud_config_'.$name.'%']);
|
||||
|
Reference in New Issue
Block a user