Commit 5dfe0e01 by Damien Moulard

WIP create button to disable cotisation bonification

parent f0844afc
......@@ -308,7 +308,7 @@ services:
admin.adherent.profilsdecotisation:
class: App\Admin\ProfilDeCotisationAdmin
arguments: [~, App\Entity\ProfilDeCotisation, ~]
arguments: [~, App\Entity\ProfilDeCotisation, App\Controller\ProfilDeCotisationAdminController]
tags:
- name: sonata.admin
manager_type: orm
......
......@@ -9,7 +9,11 @@ use Sonata\AdminBundle\Form\FormMapper;
use Sonata\Form\Type\DateTimeRangePickerType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Sonata\AdminBundle\Admin\FieldDescriptionInterface;
use Knp\Menu\ItemInterface as MenuItemInterface;
use Sonata\AdminBundle\Admin\AdminInterface;
use App\Enum\CurrencyEnum;
use Sonata\AdminBundle\Route\RouteCollection;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
/**
* Administration des profils de cotisation.
......@@ -87,4 +91,23 @@ class ProfilDeCotisationAdmin extends AbstractAdmin
])
;
}
protected function configureRoutes(RouteCollection $collection)
{
$collection->add('disablepositivecotisations');
}
protected function configureSideMenu(MenuItemInterface $menu, $action, AdminInterface $childAdmin = null)
{
if (!$childAdmin && !in_array($action, ['list'])) {
return;
}
// TODO exception rendered: route doesn't exist
$menu->addChild("Désactiver les cotisations bonifiées", [
'uri' => "#",
// 'uri' => $this->getConfigurationPool()->getContainer()->get('router')->generate('disablepositivecotisations', [], UrlGeneratorInterface::ABSOLUTE_URL),
]);
}
}
<?php
namespace App\Controller;
use App\Utils\CustomEntityManager;
use Sonata\AdminBundle\Controller\CRUDController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Security\Core\Security;
class ProfilDeCotisationAdminController extends CRUDController
{
protected $em;
protected $security;
public function __construct(CustomEntityManager $em, Security $security)
{
$this->em = $em;
$this->security = $security;
}
/**
*
*/
public function disablepositivecotisationsAction(): Response
{
$this->addFlash('sonata_flash_success', 'Youpi ça marche');
return new RedirectResponse($this->admin->generateUrl('list'));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment