mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
fix deprecations: use fqcn for submit in controllers
This commit is contained in:
parent
24357ce3d6
commit
7922f8f181
@ -4,10 +4,12 @@ namespace Chill\MainBundle\Controller;
|
|||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\Center;
|
use Chill\MainBundle\Entity\Center;
|
||||||
use Chill\MainBundle\Form\CenterType;
|
use Chill\MainBundle\Form\CenterType;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Center controller.
|
* Center controller.
|
||||||
*
|
*
|
||||||
@ -67,7 +69,7 @@ class CenterController extends Controller
|
|||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
));
|
));
|
||||||
|
|
||||||
$form->add('submit', 'submit', array('label' => 'Create'));
|
$form->add('submit', SubmitType::class, array('label' => 'Create'));
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
@ -141,7 +143,7 @@ class CenterController extends Controller
|
|||||||
'method' => 'PUT',
|
'method' => 'PUT',
|
||||||
));
|
));
|
||||||
|
|
||||||
$form->add('submit', 'submit', array('label' => 'Update'));
|
$form->add('submit', SubmitType::class, array('label' => 'Update'));
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
* Chill is a software for social workers
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||||
* <http://www.champs-libres.coop>
|
* <http://www.champs-libres.coop>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
@ -28,44 +28,44 @@ use Chill\MainBundle\Form\Type\Export\ExportType;
|
|||||||
use Chill\MainBundle\Form\Type\Export\FormatterType;
|
use Chill\MainBundle\Form\Type\Export\FormatterType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||||
use Chill\MainBundle\Form\Type\Export\PickCenterType;
|
use Chill\MainBundle\Form\Type\Export\PickCenterType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ExportController is the controller use for exporting data.
|
* ExportController is the controller use for exporting data.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class ExportController extends Controller
|
class ExportController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Render the list of available exports
|
* Render the list of available exports
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return \Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
public function indexAction(Request $request)
|
public function indexAction(Request $request)
|
||||||
{
|
{
|
||||||
$exportManager = $this->get('chill.main.export_manager');
|
$exportManager = $this->get('chill.main.export_manager');
|
||||||
|
|
||||||
$exports = $exportManager->getExports(true);
|
$exports = $exportManager->getExports(true);
|
||||||
|
|
||||||
return $this->render('ChillMainBundle:Export:layout.html.twig', array(
|
return $this->render('ChillMainBundle:Export:layout.html.twig', array(
|
||||||
'exports' => $exports
|
'exports' => $exports
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* handle the step to build a query for an export
|
* handle the step to build a query for an export
|
||||||
*
|
*
|
||||||
* This action has three steps :
|
* This action has three steps :
|
||||||
*
|
*
|
||||||
* 1.'export', the export form. When the form is posted, the data is stored
|
* 1.'export', the export form. When the form is posted, the data is stored
|
||||||
* in the session (if valid), and then a redirection is done to next step.
|
* in the session (if valid), and then a redirection is done to next step.
|
||||||
* 2. 'formatter', the formatter form. When the form is posted, the data is
|
* 2. 'formatter', the formatter form. When the form is posted, the data is
|
||||||
* stored in the session (if valid), and then a redirection is done to next step.
|
* stored in the session (if valid), and then a redirection is done to next step.
|
||||||
* 3. 'generate': gather data from session from the previous steps, and
|
* 3. 'generate': gather data from session from the previous steps, and
|
||||||
* make a redirection to the "generate" action with data in query (HTTP GET)
|
* make a redirection to the "generate" action with data in query (HTTP GET)
|
||||||
*
|
*
|
||||||
* @param string $request
|
* @param string $request
|
||||||
* @param Request $alias
|
* @param Request $alias
|
||||||
* @return \Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
@ -75,13 +75,13 @@ class ExportController extends Controller
|
|||||||
// first check for ACL
|
// first check for ACL
|
||||||
$exportManager = $this->get('chill.main.export_manager');
|
$exportManager = $this->get('chill.main.export_manager');
|
||||||
$export = $exportManager->getExport($alias);
|
$export = $exportManager->getExport($alias);
|
||||||
|
|
||||||
if ($exportManager->isGrantedForElement($export) === FALSE) {
|
if ($exportManager->isGrantedForElement($export) === FALSE) {
|
||||||
throw $this->createAccessDeniedException('The user does not have access to this export');
|
throw $this->createAccessDeniedException('The user does not have access to this export');
|
||||||
}
|
}
|
||||||
|
|
||||||
$step = $request->query->getAlpha('step', 'centers');
|
$step = $request->query->getAlpha('step', 'centers');
|
||||||
|
|
||||||
switch ($step) {
|
switch ($step) {
|
||||||
case 'centers':
|
case 'centers':
|
||||||
return $this->selectCentersStep($request, $alias);
|
return $this->selectCentersStep($request, $alias);
|
||||||
@ -98,91 +98,91 @@ class ExportController extends Controller
|
|||||||
throw $this->createNotFoundException("The given step '$step' is invalid");
|
throw $this->createNotFoundException("The given step '$step' is invalid");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function selectCentersStep(Request $request, $alias)
|
public function selectCentersStep(Request $request, $alias)
|
||||||
{
|
{
|
||||||
/* @var $exportManager \Chill\MainBundle\Export\ExportManager */
|
/* @var $exportManager \Chill\MainBundle\Export\ExportManager */
|
||||||
$exportManager = $this->get('chill.main.export_manager');
|
$exportManager = $this->get('chill.main.export_manager');
|
||||||
|
|
||||||
$form = $this->createCreateFormExport($alias, 'centers');
|
$form = $this->createCreateFormExport($alias, 'centers');
|
||||||
|
|
||||||
$export = $exportManager->getExport($alias);
|
$export = $exportManager->getExport($alias);
|
||||||
|
|
||||||
if ($request->getMethod() === 'POST') {
|
if ($request->getMethod() === 'POST') {
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
if ($form->isValid()) {
|
if ($form->isValid()) {
|
||||||
$this->get('logger')->debug('form centers is valid', array(
|
$this->get('logger')->debug('form centers is valid', array(
|
||||||
'location' => __METHOD__));
|
'location' => __METHOD__));
|
||||||
|
|
||||||
$data = $form->getData();
|
$data = $form->getData();
|
||||||
|
|
||||||
// check ACL
|
// check ACL
|
||||||
if ($exportManager->isGrantedForElement($export, NULL,
|
if ($exportManager->isGrantedForElement($export, NULL,
|
||||||
$exportManager->getPickedCenters($data['centers'])) === FALSE) {
|
$exportManager->getPickedCenters($data['centers'])) === FALSE) {
|
||||||
throw $this->createAccessDeniedException('you do not have '
|
throw $this->createAccessDeniedException('you do not have '
|
||||||
. 'access to this export for those centers');
|
. 'access to this export for those centers');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->get('session')->set('centers_step_raw',
|
$this->get('session')->set('centers_step_raw',
|
||||||
$request->request->all());
|
$request->request->all());
|
||||||
$this->get('session')->set('centers_step', $data);
|
$this->get('session')->set('centers_step', $data);
|
||||||
|
|
||||||
return $this->redirectToRoute('chill_main_export_new', array(
|
return $this->redirectToRoute('chill_main_export_new', array(
|
||||||
'step' => $this->getNextStep('centers'),
|
'step' => $this->getNextStep('centers'),
|
||||||
'alias' => $alias
|
'alias' => $alias
|
||||||
));
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('ChillMainBundle:Export:new_centers_step.html.twig',
|
return $this->render('ChillMainBundle:Export:new_centers_step.html.twig',
|
||||||
array(
|
array(
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
'export' => $export
|
'export' => $export
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render the export form
|
* Render the export form
|
||||||
*
|
*
|
||||||
* When the method is POST, the form is stored if valid, and a redirection
|
* When the method is POST, the form is stored if valid, and a redirection
|
||||||
* is done to next step.
|
* is done to next step.
|
||||||
*
|
*
|
||||||
* @param string $alias
|
* @param string $alias
|
||||||
* @return \Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
protected function exportFormStep(Request $request, $alias)
|
protected function exportFormStep(Request $request, $alias)
|
||||||
{
|
{
|
||||||
$exportManager = $this->get('chill.main.export_manager');
|
$exportManager = $this->get('chill.main.export_manager');
|
||||||
|
|
||||||
// check we have data from the previous step (export step)
|
// check we have data from the previous step (export step)
|
||||||
$data = $this->get('session')->get('centers_step', null);
|
$data = $this->get('session')->get('centers_step', null);
|
||||||
|
|
||||||
if ($data === null) {
|
if ($data === null) {
|
||||||
|
|
||||||
return $this->redirectToRoute('chill_main_export_new', array(
|
return $this->redirectToRoute('chill_main_export_new', array(
|
||||||
'step' => $this->getNextStep('export', true),
|
'step' => $this->getNextStep('export', true),
|
||||||
'alias' => $alias
|
'alias' => $alias
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$export = $exportManager->getExport($alias);
|
$export = $exportManager->getExport($alias);
|
||||||
|
|
||||||
$form = $this->createCreateFormExport($alias, 'export', $data);
|
$form = $this->createCreateFormExport($alias, 'export', $data);
|
||||||
|
|
||||||
if ($request->getMethod() === 'POST') {
|
if ($request->getMethod() === 'POST') {
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
if ($form->isValid()) {
|
if ($form->isValid()) {
|
||||||
|
|
||||||
$this->get('logger')->debug('form export is valid', array(
|
$this->get('logger')->debug('form export is valid', array(
|
||||||
'location' => __METHOD__));
|
'location' => __METHOD__));
|
||||||
|
|
||||||
// store data for reusing in next steps
|
// store data for reusing in next steps
|
||||||
$data = $form->getData();
|
$data = $form->getData();
|
||||||
$this->get('session')->set('export_step_raw',
|
$this->get('session')->set('export_step_raw',
|
||||||
$request->request->all());
|
$request->request->all());
|
||||||
$this->get('session')->set('export_step', $data);
|
$this->get('session')->set('export_step', $data);
|
||||||
|
|
||||||
//redirect to next step
|
//redirect to next step
|
||||||
return $this->redirect(
|
return $this->redirect(
|
||||||
$this->generateUrl('chill_main_export_new', array(
|
$this->generateUrl('chill_main_export_new', array(
|
||||||
@ -194,17 +194,17 @@ class ExportController extends Controller
|
|||||||
'location' => __METHOD__));
|
'location' => __METHOD__));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('ChillMainBundle:Export:new.html.twig', array(
|
return $this->render('ChillMainBundle:Export:new.html.twig', array(
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
'export_alias' => $alias,
|
'export_alias' => $alias,
|
||||||
'export' => $export
|
'export' => $export
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create a form to show on different steps.
|
* create a form to show on different steps.
|
||||||
*
|
*
|
||||||
* @param string $alias
|
* @param string $alias
|
||||||
* @param string $step, can either be 'export', 'formatter', 'generate_export' or 'generate_formatter' (last two are used by generate action)
|
* @param string $step, can either be 'export', 'formatter', 'generate_export' or 'generate_formatter' (last two are used by generate action)
|
||||||
* @param array $data the data from previous step. Required for steps 'formatter' and 'generate_formatter'
|
* @param array $data the data from previous step. Required for steps 'formatter' and 'generate_formatter'
|
||||||
@ -215,26 +215,26 @@ class ExportController extends Controller
|
|||||||
/* @var $exportManager \Chill\MainBundle\Export\ExportManager */
|
/* @var $exportManager \Chill\MainBundle\Export\ExportManager */
|
||||||
$exportManager = $this->get('chill.main.export_manager');
|
$exportManager = $this->get('chill.main.export_manager');
|
||||||
$isGenerate = strpos($step, 'generate_') === 0;
|
$isGenerate = strpos($step, 'generate_') === 0;
|
||||||
|
|
||||||
$builder = $this->get('form.factory')
|
$builder = $this->get('form.factory')
|
||||||
->createNamedBuilder(null, FormType::class, array(), array(
|
->createNamedBuilder(null, FormType::class, array(), array(
|
||||||
'method' => $isGenerate ? 'GET' : 'POST',
|
'method' => $isGenerate ? 'GET' : 'POST',
|
||||||
'csrf_protection' => $isGenerate ? false : true,
|
'csrf_protection' => $isGenerate ? false : true,
|
||||||
));
|
));
|
||||||
|
|
||||||
if ($step === 'centers' or $step === 'generate_centers') {
|
if ($step === 'centers' or $step === 'generate_centers') {
|
||||||
$builder->add('centers', PickCenterType::class, array(
|
$builder->add('centers', PickCenterType::class, array(
|
||||||
'export_alias' => $alias
|
'export_alias' => $alias
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($step === 'export' or $step === 'generate_export') {
|
if ($step === 'export' or $step === 'generate_export') {
|
||||||
$builder->add('export', ExportType::class, array(
|
$builder->add('export', ExportType::class, array(
|
||||||
'export_alias' => $alias,
|
'export_alias' => $alias,
|
||||||
'picked_centers' => $exportManager->getPickedCenters($data['centers'])
|
'picked_centers' => $exportManager->getPickedCenters($data['centers'])
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($step === 'formatter' or $step === 'generate_formatter') {
|
if ($step === 'formatter' or $step === 'generate_formatter') {
|
||||||
$builder->add('formatter', FormatterType::class, array(
|
$builder->add('formatter', FormatterType::class, array(
|
||||||
'formatter_alias' => $exportManager
|
'formatter_alias' => $exportManager
|
||||||
@ -244,19 +244,19 @@ class ExportController extends Controller
|
|||||||
->getUsedAggregatorsAliases($data['export'])
|
->getUsedAggregatorsAliases($data['export'])
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$builder->add('submit', 'submit', array(
|
$builder->add('submit', SubmitType::class, array(
|
||||||
'label' => 'Generate'
|
'label' => 'Generate'
|
||||||
));
|
));
|
||||||
|
|
||||||
return $builder->getForm();
|
return $builder->getForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the next step. If $reverse === true, the previous step is returned.
|
* get the next step. If $reverse === true, the previous step is returned.
|
||||||
*
|
*
|
||||||
* This method provides a centralized way of handling next/previous step.
|
* This method provides a centralized way of handling next/previous step.
|
||||||
*
|
*
|
||||||
* @param string $step the current step
|
* @param string $step the current step
|
||||||
* @param boolean $reverse set to true to get the previous step
|
* @param boolean $reverse set to true to get the previous step
|
||||||
* @return string the next/current step
|
* @return string the next/current step
|
||||||
@ -265,32 +265,32 @@ class ExportController extends Controller
|
|||||||
private function getNextStep($step, $reverse = false)
|
private function getNextStep($step, $reverse = false)
|
||||||
{
|
{
|
||||||
switch($step) {
|
switch($step) {
|
||||||
case 'centers':
|
case 'centers':
|
||||||
if ($reverse !== false) {
|
if ($reverse !== false) {
|
||||||
throw new \LogicException("there is no step before 'export'");
|
throw new \LogicException("there is no step before 'export'");
|
||||||
}
|
}
|
||||||
return 'export';
|
return 'export';
|
||||||
case 'export':
|
case 'export':
|
||||||
return $reverse ? 'centers' : 'formatter';
|
return $reverse ? 'centers' : 'formatter';
|
||||||
case 'formatter' :
|
case 'formatter' :
|
||||||
return $reverse ? 'export' : 'generate';
|
return $reverse ? 'export' : 'generate';
|
||||||
case 'generate' :
|
case 'generate' :
|
||||||
if ($reverse === false) {
|
if ($reverse === false) {
|
||||||
throw new \LogicException("there is no step after 'generate'");
|
throw new \LogicException("there is no step after 'generate'");
|
||||||
}
|
}
|
||||||
return 'formatter';
|
return 'formatter';
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new \LogicException("the step $step is not defined.");
|
throw new \LogicException("the step $step is not defined.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render the form for formatter.
|
* Render the form for formatter.
|
||||||
*
|
*
|
||||||
* If the form is posted and valid, store the data in session and
|
* If the form is posted and valid, store the data in session and
|
||||||
* redirect to the next step.
|
* redirect to the next step.
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param string $alias
|
* @param string $alias
|
||||||
* @return \Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
@ -298,12 +298,12 @@ class ExportController extends Controller
|
|||||||
protected function formatterFormStep(Request $request, $alias)
|
protected function formatterFormStep(Request $request, $alias)
|
||||||
{
|
{
|
||||||
$export = $this->get('chill.main.export_manager')->getExport($alias);
|
$export = $this->get('chill.main.export_manager')->getExport($alias);
|
||||||
|
|
||||||
// check we have data from the previous step (export step)
|
// check we have data from the previous step (export step)
|
||||||
$data = $this->get('session')->get('export_step', null);
|
$data = $this->get('session')->get('export_step', null);
|
||||||
|
|
||||||
if ($data === null) {
|
if ($data === null) {
|
||||||
|
|
||||||
return $this->redirectToRoute('chill_main_export_new', array(
|
return $this->redirectToRoute('chill_main_export_new', array(
|
||||||
'step' => $this->getNextStep('formatter', true),
|
'step' => $this->getNextStep('formatter', true),
|
||||||
'alias' => $alias
|
'alias' => $alias
|
||||||
@ -311,39 +311,39 @@ class ExportController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$form = $this->createCreateFormExport($alias, 'formatter', $data);
|
$form = $this->createCreateFormExport($alias, 'formatter', $data);
|
||||||
|
|
||||||
if ($request->getMethod() === 'POST') {
|
if ($request->getMethod() === 'POST') {
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
if ($form->isValid()) {
|
if ($form->isValid()) {
|
||||||
$dataFormatter = $form->getData();
|
$dataFormatter = $form->getData();
|
||||||
$this->get('session')->set('formatter_step', $dataFormatter);
|
$this->get('session')->set('formatter_step', $dataFormatter);
|
||||||
$this->get('session')->set('formatter_step_raw',
|
$this->get('session')->set('formatter_step_raw',
|
||||||
$request->request->all());
|
$request->request->all());
|
||||||
|
|
||||||
//redirect to next step
|
//redirect to next step
|
||||||
return $this->redirect($this->generateUrl('chill_main_export_new',
|
return $this->redirect($this->generateUrl('chill_main_export_new',
|
||||||
array(
|
array(
|
||||||
'alias' => $alias,
|
'alias' => $alias,
|
||||||
'step' => $this->getNextStep('formatter')
|
'step' => $this->getNextStep('formatter')
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('ChillMainBundle:Export:new_formatter_step.html.twig',
|
return $this->render('ChillMainBundle:Export:new_formatter_step.html.twig',
|
||||||
array(
|
array(
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
'export' => $export
|
'export' => $export
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gather data stored in session from previous steps, and redirect
|
* Gather data stored in session from previous steps, and redirect
|
||||||
* to the `generate` action, compiling data from previous step in the URL
|
* to the `generate` action, compiling data from previous step in the URL
|
||||||
* (to obtain a GET HTTP query).
|
* (to obtain a GET HTTP query).
|
||||||
*
|
*
|
||||||
* The data from previous steps is removed from session.
|
* The data from previous steps is removed from session.
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param string $alias
|
* @param string $alias
|
||||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||||
@ -353,19 +353,19 @@ class ExportController extends Controller
|
|||||||
$dataCenters = $this->get('session')->get('centers_step_raw', null);
|
$dataCenters = $this->get('session')->get('centers_step_raw', null);
|
||||||
$dataFormatter = $this->get('session')->get('formatter_step_raw', null);
|
$dataFormatter = $this->get('session')->get('formatter_step_raw', null);
|
||||||
$dataExport = $this->get('session')->get('export_step_raw', null);
|
$dataExport = $this->get('session')->get('export_step_raw', null);
|
||||||
|
|
||||||
if ($dataFormatter === NULL) {
|
if ($dataFormatter === NULL) {
|
||||||
return $this->redirectToRoute('chill_main_export_new', array(
|
return $this->redirectToRoute('chill_main_export_new', array(
|
||||||
'alias' => $alias, 'step' => $this->getNextStep('generate', true)
|
'alias' => $alias, 'step' => $this->getNextStep('generate', true)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove data from session
|
// remove data from session
|
||||||
$this->get('session')->remove('export_step_raw');
|
$this->get('session')->remove('export_step_raw');
|
||||||
$this->get('session')->remove('export_step');
|
$this->get('session')->remove('export_step');
|
||||||
$this->get('session')->remove('formatter_step_raw');
|
$this->get('session')->remove('formatter_step_raw');
|
||||||
$this->get('session')->remove('formatter_step');
|
$this->get('session')->remove('formatter_step');
|
||||||
|
|
||||||
$redirectParameters = array_merge(
|
$redirectParameters = array_merge(
|
||||||
$dataFormatter,
|
$dataFormatter,
|
||||||
$dataExport,
|
$dataExport,
|
||||||
@ -373,16 +373,16 @@ class ExportController extends Controller
|
|||||||
array('alias' => $alias)
|
array('alias' => $alias)
|
||||||
);
|
);
|
||||||
unset($redirectParameters['_token']);
|
unset($redirectParameters['_token']);
|
||||||
|
|
||||||
return $this->redirectToRoute('chill_main_export_download',
|
return $this->redirectToRoute('chill_main_export_download',
|
||||||
$redirectParameters);
|
$redirectParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a report.
|
* Generate a report.
|
||||||
*
|
*
|
||||||
* This action must work with GET queries.
|
* This action must work with GET queries.
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param string $alias
|
* @param string $alias
|
||||||
* @return \Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
@ -391,26 +391,26 @@ class ExportController extends Controller
|
|||||||
{
|
{
|
||||||
/* @var $exportManager \Chill\MainBundle\Export\ExportManager */
|
/* @var $exportManager \Chill\MainBundle\Export\ExportManager */
|
||||||
$exportManager = $this->get('chill.main.export_manager');
|
$exportManager = $this->get('chill.main.export_manager');
|
||||||
|
|
||||||
$formCenters = $this->createCreateFormExport($alias, 'generate_centers');
|
$formCenters = $this->createCreateFormExport($alias, 'generate_centers');
|
||||||
$formCenters->handleRequest($request);
|
$formCenters->handleRequest($request);
|
||||||
$dataCenters = $formCenters->getData();
|
$dataCenters = $formCenters->getData();
|
||||||
|
|
||||||
$formExport = $this->createCreateFormExport($alias, 'generate_export', $dataCenters);
|
$formExport = $this->createCreateFormExport($alias, 'generate_export', $dataCenters);
|
||||||
$formExport->handleRequest($request);
|
$formExport->handleRequest($request);
|
||||||
$dataExport = $formExport->getData();
|
$dataExport = $formExport->getData();
|
||||||
|
|
||||||
$formFormatter = $this->createCreateFormExport($alias, 'generate_formatter',
|
$formFormatter = $this->createCreateFormExport($alias, 'generate_formatter',
|
||||||
$dataExport);
|
$dataExport);
|
||||||
$formFormatter->handleRequest($request);
|
$formFormatter->handleRequest($request);
|
||||||
$dataFormatter = $formFormatter->getData();
|
$dataFormatter = $formFormatter->getData();
|
||||||
|
|
||||||
$r = $exportManager->generate($alias, $dataCenters['centers'],
|
$r = $exportManager->generate($alias, $dataCenters['centers'],
|
||||||
$dataExport['export'], $dataFormatter['formatter']);
|
$dataExport['export'], $dataFormatter['formatter']);
|
||||||
|
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function downloadResultAction(Request $request, $alias)
|
public function downloadResultAction(Request $request, $alias)
|
||||||
{
|
{
|
||||||
return $this->render("ChillMainBundle:Export:download.html.twig", [
|
return $this->render("ChillMainBundle:Export:download.html.twig", [
|
||||||
|
@ -4,6 +4,7 @@ namespace Chill\MainBundle\Controller;
|
|||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
use Chill\MainBundle\Entity\RoleScope;
|
use Chill\MainBundle\Entity\RoleScope;
|
||||||
use Chill\MainBundle\Entity\PermissionsGroup;
|
use Chill\MainBundle\Entity\PermissionsGroup;
|
||||||
use Chill\MainBundle\Form\PermissionsGroupType;
|
use Chill\MainBundle\Form\PermissionsGroupType;
|
||||||
@ -32,7 +33,7 @@ class PermissionsGroupController extends Controller
|
|||||||
'entities' => $entities,
|
'entities' => $entities,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new PermissionsGroup entity.
|
* Creates a new PermissionsGroup entity.
|
||||||
*
|
*
|
||||||
@ -48,7 +49,7 @@ class PermissionsGroupController extends Controller
|
|||||||
$em->persist($permissionsGroup);
|
$em->persist($permissionsGroup);
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('admin_permissionsgroup_edit',
|
return $this->redirect($this->generateUrl('admin_permissionsgroup_edit',
|
||||||
array('id' => $permissionsGroup->getId())));
|
array('id' => $permissionsGroup->getId())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +73,7 @@ class PermissionsGroupController extends Controller
|
|||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
));
|
));
|
||||||
|
|
||||||
$form->add('submit', 'submit', array('label' => 'Create'));
|
$form->add('submit', SubmitType::class, array('label' => 'Create'));
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
@ -105,26 +106,26 @@ class PermissionsGroupController extends Controller
|
|||||||
if (!$permissionsGroup) {
|
if (!$permissionsGroup) {
|
||||||
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
|
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$translatableStringHelper = $this->get('chill.main.helper.translatable_string');
|
$translatableStringHelper = $this->get('chill.main.helper.translatable_string');
|
||||||
$roleScopes = $permissionsGroup->getRoleScopes()->toArray();
|
$roleScopes = $permissionsGroup->getRoleScopes()->toArray();
|
||||||
|
|
||||||
// sort $roleScopes by name
|
// sort $roleScopes by name
|
||||||
usort($roleScopes,
|
usort($roleScopes,
|
||||||
function(RoleScope $a, RoleScope $b) use ($translatableStringHelper) {
|
function(RoleScope $a, RoleScope $b) use ($translatableStringHelper) {
|
||||||
if ($a->getScope() === NULL) {
|
if ($a->getScope() === NULL) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if ($b->getScope() === NULL) {
|
if ($b->getScope() === NULL) {
|
||||||
return +1;
|
return +1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return strcmp(
|
return strcmp(
|
||||||
$translatableStringHelper->localize($a->getScope()->getName()),
|
$translatableStringHelper->localize($a->getScope()->getName()),
|
||||||
$translatableStringHelper->localize($b->getScope()->getName())
|
$translatableStringHelper->localize($b->getScope()->getName())
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// sort role scope by title
|
// sort role scope by title
|
||||||
/* @var $roleProvider \Chill\MainBundle\Security\RoleProvider */
|
/* @var $roleProvider \Chill\MainBundle\Security\RoleProvider */
|
||||||
$roleProvider = $this->get('chill.main.role_provider');
|
$roleProvider = $this->get('chill.main.role_provider');
|
||||||
@ -135,17 +136,17 @@ class PermissionsGroupController extends Controller
|
|||||||
$roleScopesSorted[$title][] = $roleScope;
|
$roleScopesSorted[$title][] = $roleScope;
|
||||||
}
|
}
|
||||||
ksort($roleScopesSorted);
|
ksort($roleScopesSorted);
|
||||||
|
|
||||||
return $this->render('ChillMainBundle:PermissionsGroup:show.html.twig', array(
|
return $this->render('ChillMainBundle:PermissionsGroup:show.html.twig', array(
|
||||||
'entity' => $permissionsGroup,
|
'entity' => $permissionsGroup,
|
||||||
'role_scopes_sorted' => $roleScopesSorted,
|
'role_scopes_sorted' => $roleScopesSorted,
|
||||||
'expanded_roles' => $this->getExpandedRoles($roleScopes)
|
'expanded_roles' => $this->getExpandedRoles($roleScopes)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* expand roleScopes to be easily shown in template
|
* expand roleScopes to be easily shown in template
|
||||||
*
|
*
|
||||||
* @param array $roleScopes
|
* @param array $roleScopes
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@ -154,10 +155,10 @@ class PermissionsGroupController extends Controller
|
|||||||
$expandedRoles = array();
|
$expandedRoles = array();
|
||||||
foreach ($roleScopes as $roleScope) {
|
foreach ($roleScopes as $roleScope) {
|
||||||
if (!array_key_exists($roleScope->getRole(), $expandedRoles)) {
|
if (!array_key_exists($roleScope->getRole(), $expandedRoles)) {
|
||||||
$expandedRoles[$roleScope->getRole()] =
|
$expandedRoles[$roleScope->getRole()] =
|
||||||
array_map(
|
array_map(
|
||||||
function(RoleInterface $role) {
|
function(RoleInterface $role) {
|
||||||
|
|
||||||
return $role->getRole();
|
return $role->getRole();
|
||||||
},
|
},
|
||||||
$this->get('security.role_hierarchy')
|
$this->get('security.role_hierarchy')
|
||||||
@ -186,15 +187,15 @@ class PermissionsGroupController extends Controller
|
|||||||
|
|
||||||
// create all the forms
|
// create all the forms
|
||||||
$editForm = $this->createEditForm($permissionsGroup);
|
$editForm = $this->createEditForm($permissionsGroup);
|
||||||
|
|
||||||
$deleteRoleScopesForm = array();
|
$deleteRoleScopesForm = array();
|
||||||
foreach ($permissionsGroup->getRoleScopes() as $roleScope) {
|
foreach ($permissionsGroup->getRoleScopes() as $roleScope) {
|
||||||
$deleteRoleScopesForm[$roleScope->getId()] = $this->createDeleteRoleScopeForm(
|
$deleteRoleScopesForm[$roleScope->getId()] = $this->createDeleteRoleScopeForm(
|
||||||
$permissionsGroup, $roleScope);
|
$permissionsGroup, $roleScope);
|
||||||
}
|
}
|
||||||
|
|
||||||
$addRoleScopesForm = $this->createAddRoleScopeForm($permissionsGroup);
|
$addRoleScopesForm = $this->createAddRoleScopeForm($permissionsGroup);
|
||||||
|
|
||||||
// sort role scope by title
|
// sort role scope by title
|
||||||
/* @var $roleProvider \Chill\MainBundle\Security\RoleProvider */
|
/* @var $roleProvider \Chill\MainBundle\Security\RoleProvider */
|
||||||
$roleProvider = $this->get('chill.main.role_provider');
|
$roleProvider = $this->get('chill.main.role_provider');
|
||||||
@ -211,9 +212,9 @@ class PermissionsGroupController extends Controller
|
|||||||
'role_scopes_sorted' => $roleScopesSorted,
|
'role_scopes_sorted' => $roleScopesSorted,
|
||||||
'edit_form' => $editForm->createView(),
|
'edit_form' => $editForm->createView(),
|
||||||
'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()),
|
'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()),
|
||||||
'delete_role_scopes_form' => array_map( function($form) {
|
'delete_role_scopes_form' => array_map( function($form) {
|
||||||
|
|
||||||
return $form->createView();
|
return $form->createView();
|
||||||
}, $deleteRoleScopesForm),
|
}, $deleteRoleScopesForm),
|
||||||
'add_role_scopes_form' => $addRoleScopesForm->createView()
|
'add_role_scopes_form' => $addRoleScopesForm->createView()
|
||||||
));
|
));
|
||||||
@ -233,11 +234,11 @@ class PermissionsGroupController extends Controller
|
|||||||
'method' => 'PUT',
|
'method' => 'PUT',
|
||||||
));
|
));
|
||||||
|
|
||||||
$form->add('submit', 'submit', array('label' => 'Update'));
|
$form->add('submit', SubmitType::class, array('label' => 'Update'));
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edits an existing PermissionsGroup entity.
|
* Edits an existing PermissionsGroup entity.
|
||||||
*
|
*
|
||||||
@ -259,20 +260,20 @@ class PermissionsGroupController extends Controller
|
|||||||
$editForm->handleRequest($request);
|
$editForm->handleRequest($request);
|
||||||
|
|
||||||
if ($editForm->isValid()) {
|
if ($editForm->isValid()) {
|
||||||
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('admin_permissionsgroup_edit', array('id' => $id)));
|
return $this->redirect($this->generateUrl('admin_permissionsgroup_edit', array('id' => $id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
$deleteRoleScopesForm = array();
|
$deleteRoleScopesForm = array();
|
||||||
foreach ($permissionsGroup->getRoleScopes() as $roleScope) {
|
foreach ($permissionsGroup->getRoleScopes() as $roleScope) {
|
||||||
$deleteRoleScopesForm[$roleScope->getId()] = $this->createDeleteRoleScopeForm(
|
$deleteRoleScopesForm[$roleScope->getId()] = $this->createDeleteRoleScopeForm(
|
||||||
$permissionsGroup, $roleScope);
|
$permissionsGroup, $roleScope);
|
||||||
}
|
}
|
||||||
|
|
||||||
$addRoleScopesForm = $this->createAddRoleScopeForm($permissionsGroup);
|
$addRoleScopesForm = $this->createAddRoleScopeForm($permissionsGroup);
|
||||||
|
|
||||||
// sort role scope by title
|
// sort role scope by title
|
||||||
/* @var $roleProvider \Chill\MainBundle\Security\RoleProvider */
|
/* @var $roleProvider \Chill\MainBundle\Security\RoleProvider */
|
||||||
$roleProvider = $this->get('chill.main.role_provider');
|
$roleProvider = $this->get('chill.main.role_provider');
|
||||||
@ -283,100 +284,100 @@ class PermissionsGroupController extends Controller
|
|||||||
$roleScopesSorted[$title][] = $roleScope;
|
$roleScopesSorted[$title][] = $roleScope;
|
||||||
}
|
}
|
||||||
ksort($roleScopesSorted);
|
ksort($roleScopesSorted);
|
||||||
|
|
||||||
return $this->render('ChillMainBundle:PermissionsGroup:edit.html.twig', array(
|
return $this->render('ChillMainBundle:PermissionsGroup:edit.html.twig', array(
|
||||||
'entity' => $permissionsGroup,
|
'entity' => $permissionsGroup,
|
||||||
'role_scopes_sorted' => $roleScopesSorted,
|
'role_scopes_sorted' => $roleScopesSorted,
|
||||||
'edit_form' => $editForm->createView(),
|
'edit_form' => $editForm->createView(),
|
||||||
'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()),
|
'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()),
|
||||||
'delete_role_scopes_form' => array_map( function($form) {
|
'delete_role_scopes_form' => array_map( function($form) {
|
||||||
|
|
||||||
return $form->createView();
|
return $form->createView();
|
||||||
}, $deleteRoleScopesForm),
|
}, $deleteRoleScopesForm),
|
||||||
'add_role_scopes_form' => $addRoleScopesForm->createView()
|
'add_role_scopes_form' => $addRoleScopesForm->createView()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get a role scope by his parameters. The role scope is persisted if it
|
* get a role scope by his parameters. The role scope is persisted if it
|
||||||
* doesn't exists in database.
|
* doesn't exists in database.
|
||||||
*
|
*
|
||||||
* @param Scope $scope
|
* @param Scope $scope
|
||||||
* @param string $role
|
* @param string $role
|
||||||
* @return RoleScope
|
* @return RoleScope
|
||||||
*/
|
*/
|
||||||
protected function getPersistentRoleScopeBy($role, Scope $scope = null)
|
protected function getPersistentRoleScopeBy($role, Scope $scope = null)
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
$roleScope = $em->getRepository('ChillMainBundle:RoleScope')
|
$roleScope = $em->getRepository('ChillMainBundle:RoleScope')
|
||||||
->findOneBy(array('role' => $role, 'scope' => $scope));
|
->findOneBy(array('role' => $role, 'scope' => $scope));
|
||||||
|
|
||||||
if ($roleScope === NULL) {
|
if ($roleScope === NULL) {
|
||||||
$roleScope = (new RoleScope())
|
$roleScope = (new RoleScope())
|
||||||
->setRole($role)
|
->setRole($role)
|
||||||
->setScope($scope)
|
->setScope($scope)
|
||||||
;
|
;
|
||||||
|
|
||||||
$em->persist($roleScope);
|
$em->persist($roleScope);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $roleScope;
|
return $roleScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* remove an association between permissionsGroup and roleScope
|
* remove an association between permissionsGroup and roleScope
|
||||||
*
|
*
|
||||||
* @param int $pgid permissionsGroup id
|
* @param int $pgid permissionsGroup id
|
||||||
* @param int $rsid roleScope id
|
* @param int $rsid roleScope id
|
||||||
* @return redirection to edit form
|
* @return redirection to edit form
|
||||||
*/
|
*/
|
||||||
public function deleteLinkRoleScopeAction($pgid, $rsid)
|
public function deleteLinkRoleScopeAction($pgid, $rsid)
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
$permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($pgid);
|
$permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($pgid);
|
||||||
$roleScope = $em->getRepository('ChillMainBundle:RoleScope')->find($rsid);
|
$roleScope = $em->getRepository('ChillMainBundle:RoleScope')->find($rsid);
|
||||||
|
|
||||||
if (!$permissionsGroup) {
|
if (!$permissionsGroup) {
|
||||||
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
|
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$roleScope) {
|
if (!$roleScope) {
|
||||||
throw $this->createNotFoundException('Unable to find RoleScope entity');
|
throw $this->createNotFoundException('Unable to find RoleScope entity');
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$permissionsGroup->removeRoleScope($roleScope);
|
$permissionsGroup->removeRoleScope($roleScope);
|
||||||
} catch (\RuntimeException $ex) {
|
} catch (\RuntimeException $ex) {
|
||||||
$this->addFlash('notice',
|
$this->addFlash('notice',
|
||||||
$this->get('translator')->trans("The role '%role%' and circle "
|
$this->get('translator')->trans("The role '%role%' and circle "
|
||||||
. "'%scope%' is not associated with this permission group", array(
|
. "'%scope%' is not associated with this permission group", array(
|
||||||
'%role%' => $this->get('translator')->trans($roleScope->getRole()),
|
'%role%' => $this->get('translator')->trans($roleScope->getRole()),
|
||||||
'%scope%' => $this->get('chill.main.helper.translatable_string')
|
'%scope%' => $this->get('chill.main.helper.translatable_string')
|
||||||
->localize($roleScope->getScope()->getName())
|
->localize($roleScope->getScope()->getName())
|
||||||
)));
|
)));
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('admin_permissionsgroup_edit',
|
return $this->redirect($this->generateUrl('admin_permissionsgroup_edit',
|
||||||
array('id' => $pgid)));
|
array('id' => $pgid)));
|
||||||
}
|
}
|
||||||
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
$this->addFlash('notice',
|
$this->addFlash('notice',
|
||||||
$this->get('translator')->trans("The role '%role%' on circle "
|
$this->get('translator')->trans("The role '%role%' on circle "
|
||||||
. "'%scope%' has been removed", array(
|
. "'%scope%' has been removed", array(
|
||||||
'%role%' => $this->get('translator')->trans($roleScope->getRole()),
|
'%role%' => $this->get('translator')->trans($roleScope->getRole()),
|
||||||
'%scope%' => $this->get('chill.main.helper.translatable_string')
|
'%scope%' => $this->get('chill.main.helper.translatable_string')
|
||||||
->localize($roleScope->getScope()->getName())
|
->localize($roleScope->getScope()->getName())
|
||||||
)));
|
)));
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('admin_permissionsgroup_edit',
|
return $this->redirect($this->generateUrl('admin_permissionsgroup_edit',
|
||||||
array('id' => $pgid)));
|
array('id' => $pgid)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* @return Respon
|
* @return Respon
|
||||||
@ -391,26 +392,26 @@ class PermissionsGroupController extends Controller
|
|||||||
if (!$permissionsGroup) {
|
if (!$permissionsGroup) {
|
||||||
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
|
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$form = $this->createAddRoleScopeForm($permissionsGroup);
|
$form = $this->createAddRoleScopeForm($permissionsGroup);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
if ($form->isValid()) {
|
if ($form->isValid()) {
|
||||||
$roleScope = $this->getPersistentRoleScopeBy(
|
$roleScope = $this->getPersistentRoleScopeBy(
|
||||||
$form['composed_role_scope']->getData()->getRole(),
|
$form['composed_role_scope']->getData()->getRole(),
|
||||||
$form['composed_role_scope']->getData()->getScope()
|
$form['composed_role_scope']->getData()->getScope()
|
||||||
);
|
);
|
||||||
|
|
||||||
$permissionsGroup->addRoleScope($roleScope);
|
$permissionsGroup->addRoleScope($roleScope);
|
||||||
$violations = $this->get('validator')->validate($permissionsGroup);
|
$violations = $this->get('validator')->validate($permissionsGroup);
|
||||||
|
|
||||||
if ($violations->count() === 0) {
|
if ($violations->count() === 0) {
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
$this->addFlash('notice',
|
$this->addFlash('notice',
|
||||||
$this->get('translator')->trans("The permissions have been added"));
|
$this->get('translator')->trans("The permissions have been added"));
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('admin_permissionsgroup_edit',
|
return $this->redirect($this->generateUrl('admin_permissionsgroup_edit',
|
||||||
array('id' => $id)));
|
array('id' => $id)));
|
||||||
} else {
|
} else {
|
||||||
foreach($violations as $error) {
|
foreach($violations as $error) {
|
||||||
@ -423,17 +424,17 @@ class PermissionsGroupController extends Controller
|
|||||||
$this->addFlash('error', $error->getMessage());
|
$this->addFlash('error', $error->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$editForm = $this->createEditForm($permissionsGroup);
|
$editForm = $this->createEditForm($permissionsGroup);
|
||||||
|
|
||||||
$deleteRoleScopesForm = array();
|
$deleteRoleScopesForm = array();
|
||||||
foreach ($permissionsGroup->getRoleScopes() as $roleScope) {
|
foreach ($permissionsGroup->getRoleScopes() as $roleScope) {
|
||||||
$deleteRoleScopesForm[$roleScope->getId()] = $this->createDeleteRoleScopeForm(
|
$deleteRoleScopesForm[$roleScope->getId()] = $this->createDeleteRoleScopeForm(
|
||||||
$permissionsGroup, $roleScope);
|
$permissionsGroup, $roleScope);
|
||||||
}
|
}
|
||||||
|
|
||||||
$addRoleScopesForm = $this->createAddRoleScopeForm($permissionsGroup);
|
$addRoleScopesForm = $this->createAddRoleScopeForm($permissionsGroup);
|
||||||
|
|
||||||
// sort role scope by title
|
// sort role scope by title
|
||||||
/* @var $roleProvider \Chill\MainBundle\Security\RoleProvider */
|
/* @var $roleProvider \Chill\MainBundle\Security\RoleProvider */
|
||||||
$roleProvider = $this->get('chill.main.role_provider');
|
$roleProvider = $this->get('chill.main.role_provider');
|
||||||
@ -450,15 +451,15 @@ class PermissionsGroupController extends Controller
|
|||||||
'edit_form' => $editForm->createView(),
|
'edit_form' => $editForm->createView(),
|
||||||
'role_scopes_sorted' => $roleScopesSorted,
|
'role_scopes_sorted' => $roleScopesSorted,
|
||||||
'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()),
|
'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()),
|
||||||
'delete_role_scopes_form' => array_map( function($form) {
|
'delete_role_scopes_form' => array_map( function($form) {
|
||||||
|
|
||||||
return $form->createView();
|
return $form->createView();
|
||||||
}, $deleteRoleScopesForm),
|
}, $deleteRoleScopesForm),
|
||||||
'add_role_scopes_form' => $addRoleScopesForm->createView()
|
'add_role_scopes_form' => $addRoleScopesForm->createView()
|
||||||
));
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a form to delete a link to roleScope.
|
* Creates a form to delete a link to roleScope.
|
||||||
*
|
*
|
||||||
@ -470,17 +471,17 @@ class PermissionsGroupController extends Controller
|
|||||||
RoleScope $roleScope)
|
RoleScope $roleScope)
|
||||||
{
|
{
|
||||||
return $this->createFormBuilder()
|
return $this->createFormBuilder()
|
||||||
->setAction($this->generateUrl('admin_permissionsgroup_delete_role_scope',
|
->setAction($this->generateUrl('admin_permissionsgroup_delete_role_scope',
|
||||||
array('pgid' => $permissionsGroup->getId(), 'rsid' => $roleScope->getId())))
|
array('pgid' => $permissionsGroup->getId(), 'rsid' => $roleScope->getId())))
|
||||||
->setMethod('DELETE')
|
->setMethod('DELETE')
|
||||||
->add('submit', 'submit', array('label' => 'Delete'))
|
->add('submit', SubmitType::class, array('label' => 'Delete'))
|
||||||
->getForm()
|
->getForm()
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* creates a form to add a role scope to permissionsgroup
|
* creates a form to add a role scope to permissionsgroup
|
||||||
*
|
*
|
||||||
* @param PermissionsGroup $permissionsGroup
|
* @param PermissionsGroup $permissionsGroup
|
||||||
* @return \Symfony\Component\Form\Form The form
|
* @return \Symfony\Component\Form\Form The form
|
||||||
*/
|
*/
|
||||||
@ -491,10 +492,10 @@ class PermissionsGroupController extends Controller
|
|||||||
array('id' => $permissionsGroup->getId())))
|
array('id' => $permissionsGroup->getId())))
|
||||||
->setMethod('PUT')
|
->setMethod('PUT')
|
||||||
->add('composed_role_scope', 'composed_role_scope')
|
->add('composed_role_scope', 'composed_role_scope')
|
||||||
->add('submit', 'submit', array('label' => 'Add permission'))
|
->add('submit', SubmitType::class, array('label' => 'Add permission'))
|
||||||
->getForm()
|
->getForm()
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ namespace Chill\MainBundle\Controller;
|
|||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Chill\MainBundle\Form\UserType;
|
use Chill\MainBundle\Form\UserType;
|
||||||
@ -11,13 +12,14 @@ use Chill\MainBundle\Entity\GroupCenter;
|
|||||||
use Chill\MainBundle\Form\Type\ComposedGroupCenterType;
|
use Chill\MainBundle\Form\Type\ComposedGroupCenterType;
|
||||||
use Chill\MainBundle\Form\UserPasswordType;
|
use Chill\MainBundle\Form\UserPasswordType;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User controller.
|
* User controller.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class UserController extends Controller
|
class UserController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
const FORM_GROUP_CENTER_COMPOSED = 'composed_groupcenter';
|
const FORM_GROUP_CENTER_COMPOSED = 'composed_groupcenter';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,10 +48,10 @@ class UserController extends Controller
|
|||||||
|
|
||||||
if ($form->isValid()) {
|
if ($form->isValid()) {
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
$user->setPassword($this->get('security.password_encoder')
|
$user->setPassword($this->get('security.password_encoder')
|
||||||
->encodePassword($user, $form['plainPassword']['password']->getData()));
|
->encodePassword($user, $form['plainPassword']['password']->getData()));
|
||||||
|
|
||||||
$em->persist($user);
|
$em->persist($user);
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
@ -77,7 +79,7 @@ class UserController extends Controller
|
|||||||
'is_creation' => true
|
'is_creation' => true
|
||||||
));
|
));
|
||||||
|
|
||||||
$form->add('submit', 'submit', array('label' => 'Create'));
|
$form->add('submit', SubmitType::class, array('label' => 'Create'));
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
@ -136,15 +138,15 @@ class UserController extends Controller
|
|||||||
'entity' => $user,
|
'entity' => $user,
|
||||||
'edit_form' => $editForm->createView(),
|
'edit_form' => $editForm->createView(),
|
||||||
'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($user)->createView(),
|
'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($user)->createView(),
|
||||||
'delete_groupcenter_form' => array_map(
|
'delete_groupcenter_form' => array_map(
|
||||||
function(\Symfony\Component\Form\Form $form) {
|
function(\Symfony\Component\Form\Form $form) {
|
||||||
return $form->createView();
|
return $form->createView();
|
||||||
|
|
||||||
},
|
},
|
||||||
iterator_to_array($this->getDeleteLinkGroupCenterByUser($user), true))
|
iterator_to_array($this->getDeleteLinkGroupCenterByUser($user), true))
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a form to edit the user password.
|
* Displays a form to edit the user password.
|
||||||
*
|
*
|
||||||
@ -166,25 +168,25 @@ class UserController extends Controller
|
|||||||
'edit_form' => $editForm->createView()
|
'edit_form' => $editForm->createView()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @return \Symfony\Component\Form\Form
|
* @return \Symfony\Component\Form\Form
|
||||||
*/
|
*/
|
||||||
private function createEditPasswordForm(User $user)
|
private function createEditPasswordForm(User $user)
|
||||||
{
|
{
|
||||||
return $this->createForm(new UserPasswordType(), $user, array(
|
return $this->createForm(new UserPasswordType(), $user, array(
|
||||||
'action' =>
|
'action' =>
|
||||||
$this->generateUrl('admin_user_update_password', array('id' => $user->getId())),
|
$this->generateUrl('admin_user_update_password', array('id' => $user->getId())),
|
||||||
'method' => 'PUT'
|
'method' => 'PUT'
|
||||||
))
|
))
|
||||||
->add('submit', 'submit', array('label' => 'Change password'))
|
->add('submit', SubmitType::class, array('label' => 'Change password'))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteLinkGroupCenterAction($uid, $gcid)
|
public function deleteLinkGroupCenterAction($uid, $gcid)
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
@ -193,32 +195,32 @@ class UserController extends Controller
|
|||||||
if (!$user) {
|
if (!$user) {
|
||||||
throw $this->createNotFoundException('Unable to find User entity.');
|
throw $this->createNotFoundException('Unable to find User entity.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$groupCenter = $em->getRepository('ChillMainBundle:GroupCenter')
|
$groupCenter = $em->getRepository('ChillMainBundle:GroupCenter')
|
||||||
->find($gcid);
|
->find($gcid);
|
||||||
|
|
||||||
if (!$groupCenter) {
|
if (!$groupCenter) {
|
||||||
throw $this->createNotFoundException('Unable to find groupCenter entity');
|
throw $this->createNotFoundException('Unable to find groupCenter entity');
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$user->removeGroupCenter($groupCenter);
|
$user->removeGroupCenter($groupCenter);
|
||||||
} catch (\RuntimeException $ex) {
|
} catch (\RuntimeException $ex) {
|
||||||
$this->addFlash('error', $this->get('translator')->trans($ex-getMessage()));
|
$this->addFlash('error', $this->get('translator')->trans($ex-getMessage()));
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('admin_user_edit', array('id' => $uid)));
|
return $this->redirect($this->generateUrl('admin_user_edit', array('id' => $uid)));
|
||||||
}
|
}
|
||||||
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
$this->addFlash('success', $this->get('translator')
|
$this->addFlash('success', $this->get('translator')
|
||||||
->trans('The permissions where removed.'));
|
->trans('The permissions where removed.'));
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('admin_user_edit', array('id' => $uid)));
|
return $this->redirect($this->generateUrl('admin_user_edit', array('id' => $uid)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addLinkGroupCenterAction(Request $request, $uid)
|
public function addLinkGroupCenterAction(Request $request, $uid)
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
@ -227,21 +229,21 @@ class UserController extends Controller
|
|||||||
if (!$user) {
|
if (!$user) {
|
||||||
throw $this->createNotFoundException('Unable to find User entity.');
|
throw $this->createNotFoundException('Unable to find User entity.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$form = $this->createAddLinkGroupCenterForm($user);
|
$form = $this->createAddLinkGroupCenterForm($user);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
if ($form->isValid()) {
|
if ($form->isValid()) {
|
||||||
$groupCenter = $this->getPersistedGroupCenter(
|
$groupCenter = $this->getPersistedGroupCenter(
|
||||||
$form[self::FORM_GROUP_CENTER_COMPOSED]->getData());
|
$form[self::FORM_GROUP_CENTER_COMPOSED]->getData());
|
||||||
$user->addGroupCenter($groupCenter);
|
$user->addGroupCenter($groupCenter);
|
||||||
|
|
||||||
if ($this->get('validator')->validate($user)->count() === 0) {
|
if ($this->get('validator')->validate($user)->count() === 0) {
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
$this->addFlash('success', $this->get('translator')->trans('The '
|
$this->addFlash('success', $this->get('translator')->trans('The '
|
||||||
. 'permissions have been successfully added to the user'));
|
. 'permissions have been successfully added to the user'));
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('admin_user_edit',
|
return $this->redirect($this->generateUrl('admin_user_edit',
|
||||||
array('id' => $uid)));
|
array('id' => $uid)));
|
||||||
} else {
|
} else {
|
||||||
@ -249,35 +251,35 @@ class UserController extends Controller
|
|||||||
$this->addFlash('error', $error->getMessage());
|
$this->addFlash('error', $error->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('ChillMainBundle:User:edit.html.twig', array(
|
return $this->render('ChillMainBundle:User:edit.html.twig', array(
|
||||||
'entity' => $user,
|
'entity' => $user,
|
||||||
'edit_form' => $this->createEditForm($user)->createView(),
|
'edit_form' => $this->createEditForm($user)->createView(),
|
||||||
'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($user)->createView(),
|
'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($user)->createView(),
|
||||||
'delete_groupcenter_form' => array_map(
|
'delete_groupcenter_form' => array_map(
|
||||||
function(\Symfony\Component\Form\Form $form) {
|
function(\Symfony\Component\Form\Form $form) {
|
||||||
return $form->createView();
|
return $form->createView();
|
||||||
|
|
||||||
},
|
},
|
||||||
iterator_to_array($this->getDeleteLinkGroupCenterByUser($user), true))
|
iterator_to_array($this->getDeleteLinkGroupCenterByUser($user), true))
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getPersistedGroupCenter(GroupCenter $groupCenter)
|
private function getPersistedGroupCenter(GroupCenter $groupCenter)
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
$groupCenterManaged = $em->getRepository('ChillMainBundle:GroupCenter')
|
$groupCenterManaged = $em->getRepository('ChillMainBundle:GroupCenter')
|
||||||
->findOneBy(array(
|
->findOneBy(array(
|
||||||
'center' => $groupCenter->getCenter(),
|
'center' => $groupCenter->getCenter(),
|
||||||
'permissionsGroup' => $groupCenter->getPermissionsGroup()
|
'permissionsGroup' => $groupCenter->getPermissionsGroup()
|
||||||
));
|
));
|
||||||
|
|
||||||
if (!$groupCenterManaged) {
|
if (!$groupCenterManaged) {
|
||||||
$em->persist($groupCenter);
|
$em->persist($groupCenter);
|
||||||
return $groupCenter;
|
return $groupCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $groupCenterManaged;
|
return $groupCenterManaged;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,11 +297,11 @@ class UserController extends Controller
|
|||||||
'method' => 'PUT',
|
'method' => 'PUT',
|
||||||
));
|
));
|
||||||
|
|
||||||
$form->add('submit', 'submit', array('label' => 'Update'));
|
$form->add('submit', SubmitType::class, array('label' => 'Update'));
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edits an existing User entity.
|
* Edits an existing User entity.
|
||||||
*
|
*
|
||||||
@ -327,15 +329,15 @@ class UserController extends Controller
|
|||||||
'entity' => $user,
|
'entity' => $user,
|
||||||
'edit_form' => $editForm->createView(),
|
'edit_form' => $editForm->createView(),
|
||||||
'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($user)->createView(),
|
'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($user)->createView(),
|
||||||
'delete_groupcenter_form' => array_map(
|
'delete_groupcenter_form' => array_map(
|
||||||
function(\Symfony\Component\Form\Form $form) {
|
function(\Symfony\Component\Form\Form $form) {
|
||||||
return $form->createView();
|
return $form->createView();
|
||||||
|
|
||||||
},
|
},
|
||||||
iterator_to_array($this->getDeleteLinkGroupCenterByUser($user), true))
|
iterator_to_array($this->getDeleteLinkGroupCenterByUser($user), true))
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edits the user password
|
* Edits the user password
|
||||||
*
|
*
|
||||||
@ -355,20 +357,20 @@ class UserController extends Controller
|
|||||||
|
|
||||||
if ($editForm->isValid()) {
|
if ($editForm->isValid()) {
|
||||||
$password = $editForm->getData()->getPassword();
|
$password = $editForm->getData()->getPassword();
|
||||||
|
|
||||||
// logging for debug !! WARNING print the new password !!
|
// logging for debug !! WARNING print the new password !!
|
||||||
$this->get('logger')->debug('update password for an user',
|
$this->get('logger')->debug('update password for an user',
|
||||||
array('method' => __METHOD__, 'password' => $password,
|
array('method' => __METHOD__, 'password' => $password,
|
||||||
'user' => $user->getUsername()));
|
'user' => $user->getUsername()));
|
||||||
// logging for prod
|
// logging for prod
|
||||||
$this->get('logger')->info('update password for an user',
|
$this->get('logger')->info('update password for an user',
|
||||||
array('method' => __METHOD__, 'user' => $user->getUsername()));
|
array('method' => __METHOD__, 'user' => $user->getUsername()));
|
||||||
|
|
||||||
$user->setPassword($this->get('security.password_encoder')
|
$user->setPassword($this->get('security.password_encoder')
|
||||||
->encodePassword($user, $password));
|
->encodePassword($user, $password));
|
||||||
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
$this->addFlash('success', $this->get('translator')->trans('Password successfully updated!'));
|
$this->addFlash('success', $this->get('translator')->trans('Password successfully updated!'));
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('admin_user_edit', array('id' => $id)));
|
return $this->redirect($this->generateUrl('admin_user_edit', array('id' => $id)));
|
||||||
@ -380,7 +382,7 @@ class UserController extends Controller
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a form to delete a link to a GroupCenter
|
* Creates a form to delete a link to a GroupCenter
|
||||||
*
|
*
|
||||||
@ -391,34 +393,34 @@ class UserController extends Controller
|
|||||||
private function createDeleteLinkGroupCenterForm(User $user, GroupCenter $groupCenter)
|
private function createDeleteLinkGroupCenterForm(User $user, GroupCenter $groupCenter)
|
||||||
{
|
{
|
||||||
return $this->createFormBuilder()
|
return $this->createFormBuilder()
|
||||||
->setAction($this->generateUrl('admin_user_delete_group_center',
|
->setAction($this->generateUrl('admin_user_delete_group_center',
|
||||||
array('uid' => $user->getId(), 'gcid' => $groupCenter->getId())))
|
array('uid' => $user->getId(), 'gcid' => $groupCenter->getId())))
|
||||||
->setMethod('DELETE')
|
->setMethod('DELETE')
|
||||||
->add('submit', 'submit', array('label' => 'Delete'))
|
->add('submit', SubmitType::class, array('label' => 'Delete'))
|
||||||
->getForm()
|
->getForm()
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create a form to add a link to a groupcenter
|
* create a form to add a link to a groupcenter
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @return \Symfony\Component\Form\Form
|
* @return \Symfony\Component\Form\Form
|
||||||
*/
|
*/
|
||||||
private function createAddLinkGroupCenterForm(User $user)
|
private function createAddLinkGroupCenterForm(User $user)
|
||||||
{
|
{
|
||||||
return $this->createFormBuilder()
|
return $this->createFormBuilder()
|
||||||
->setAction($this->generateUrl('admin_user_add_group_center',
|
->setAction($this->generateUrl('admin_user_add_group_center',
|
||||||
array('uid' => $user->getId())))
|
array('uid' => $user->getId())))
|
||||||
->setMethod('POST')
|
->setMethod('POST')
|
||||||
->add(self::FORM_GROUP_CENTER_COMPOSED, new ComposedGroupCenterType())
|
->add(self::FORM_GROUP_CENTER_COMPOSED, new ComposedGroupCenterType())
|
||||||
->add('submit', 'submit', array('label' => 'Add a new groupCenter'))
|
->add('submit', SubmitType::class, array('label' => 'Add a new groupCenter'))
|
||||||
->getForm()
|
->getForm()
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*/
|
*/
|
||||||
private function getDeleteLinkGroupCenterByUser(User $user)
|
private function getDeleteLinkGroupCenterByUser(User $user)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user