Procházet zdrojové kódy

acces by role, crud

master
Charly před 3 roky
rodič
revize
1ff0360833
7 změnil soubory, kde provedl 116 přidání a 24 odebrání
  1. +7
    -1
      config/packages/lc_sov.yaml
  2. +4
    -0
      config/routes.yaml
  3. +49
    -0
      src/Controller/Admin/DashboardAnimatorController.php
  4. +49
    -21
      src/Controller/Admin/DashboardController.php
  5. +2
    -2
      src/Controller/Admin/UserCrudController.php
  6. +4
    -0
      src/Entity/CollectifData.php
  7. +1
    -0
      translations/admin.fr.yaml

+ 7
- 1
config/packages/lc_sov.yaml Zobrazit soubor

@@ -1,3 +1,9 @@
# see https://symfony.com/doc/current/reference/configuration/framework.html
lc_sov:
homepage_route: 'app_homepage'
homepage_route: 'app_homepage'
login_redirection:
redirect_referer: false
roles_redirection:
- { role: "ROLE_ADMIN", redirect: "admin_dashboard" }
- { role: "ROLE_ANIMATOR", redirect: "admin_dashboard_animator" }
- { role: "ROLE_SUPER_ADMIN", redirect: "admin_dashboard" }

+ 4
- 0
config/routes.yaml Zobrazit soubor

@@ -6,6 +6,10 @@ admin_dashboard:
path: /admin
controller: App\Controller\Admin\DashboardController::index

admin_dashboard_animator:
path: /admin-animator
controller: App\Controller\Admin\DashboardAnimatorController::index

app_homepage:
path: /
controller: App\Controller\Frontend\DefaultController:home

+ 49
- 0
src/Controller/Admin/DashboardAnimatorController.php Zobrazit soubor

@@ -0,0 +1,49 @@
<?php

namespace App\Controller\Admin;


use App\Entity\CollectifData;
use App\Entity\Common\TaxRate;
use App\Entity\Configuration;
use App\Entity\IndividualData;
use App\Entity\Site\Page;
use App\Entity\Territory;
use App\Entity\Thematic;
use App\Entity\User\GroupUser;
use App\Entity\User\User;
use EasyCorp\Bundle\EasyAdminBundle\Config\Assets;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
use Lc\SovBundle\Controller\Admin\DashboardController as SovDashboardController;
use Symfony\Component\HttpFoundation\Response;

class DashboardAnimatorController extends SovDashboardController
{
private $adminUrlGenerator;

public function __construct(AdminUrlGenerator $adminUrlGenerator)
{
$this->adminUrlGenerator = $adminUrlGenerator;
}

public function configureMenuItems(): iterable
{
$urlCreate = $this->adminUrlGenerator
->setController(CollectifDataCrudController::class)
->setAction('new')
->generateUrl();

yield MenuItem::linkToDashboard('dashboard', 'circle');
yield MenuItem::subMenu('account', 'user')
->setSubItems(
[
MenuItem::linkToRoute('account_profile', '', 'sov_admin_account_profile'),
MenuItem::linkToRoute('account_password', '', 'sov_admin_account_password'),
]
);
yield MenuItem::linkToUrl('data_collectif_create', '', $urlCreate);

}
}

+ 49
- 21
src/Controller/Admin/DashboardController.php Zobrazit soubor

@@ -3,6 +3,7 @@
namespace App\Controller\Admin;


use App\Entity\CollectifData;
use App\Entity\Common\TaxRate;
use App\Entity\Configuration;
use App\Entity\IndividualData;
@@ -14,40 +15,67 @@ use App\Entity\User\User;
use EasyCorp\Bundle\EasyAdminBundle\Config\Assets;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
use Lc\SovBundle\Controller\Admin\DashboardController as SovDashboardController;

class DashboardController extends SovDashboardController
{
const ROLE_ADMIN = "ROLE_ADMIN";
const ROLE_SUPER_ADMIN = "ROLE_SUPER_ADMIN";

private $adminUrlGenerator;

public function __construct(AdminUrlGenerator $adminUrlGenerator)
{
$this->adminUrlGenerator = $adminUrlGenerator;
}

public function configureMenuItems(): iterable
{

$urlCreate = $this->adminUrlGenerator
->setController(CollectifDataCrudController::class)
->setAction('new')
->generateUrl();

yield MenuItem::linkToDashboard('dashboard', 'circle');
yield MenuItem::linkToCrud('page', 'copy', Page::class);
yield MenuItem::subMenu('account', 'user')->setSubItems(
[
MenuItem::linkToRoute('account_profile', '', 'sov_admin_account_profile'),
MenuItem::linkToRoute('account_password', '', 'sov_admin_account_password'),
]
);
yield MenuItem::subMenu('user', 'user')->setSubItems(
yield MenuItem::subMenu('account', 'user')
->setSubItems(
[
MenuItem::linkToRoute('account_profile', '', 'sov_admin_account_profile'),
MenuItem::linkToRoute('account_password', '', 'sov_admin_account_password'),
]
);
yield MenuItem::subMenu('user', 'user')
->setPermission(self::ROLE_ADMIN)
->setSubItems(
[
MenuItem::linkToCrud('user_index', '', User::class),
MenuItem::linkToCrud('user_index', '', User::class),
]
);
yield MenuItem::subMenu('data_individual', 'user')->setSubItems(
);
yield MenuItem::subMenu('data_individual', 'user')
->setPermission(self::ROLE_ADMIN)
->setSubItems(
[
MenuItem::linkToCrud('data_individual_validate', '', IndividualData::class),
MenuItem::linkToCrud('data_individual_waiting', '', IndividualData::class),
MenuItem::linkToCrud('data_individual_validate', '', IndividualData::class),
MenuItem::linkToCrud('data_individual_waiting', '', IndividualData::class),
]
);
yield MenuItem::subMenu('data_collectif', 'user')->setSubItems(
);
yield MenuItem::subMenu('data_collectif', 'user')
->setPermission(self::ROLE_ADMIN)
->setSubItems(
[
MenuItem::linkToCrud('data_collectif_validate', '', IndividualData::class),
MenuItem::linkToCrud('data_collectif_waiting', '', IndividualData::class),
MenuItem::linkToCrud('data_collectif_validate', '', CollectifData::class),
MenuItem::linkToCrud('data_collectif_waiting', '', CollectifData::class),
]
);
yield MenuItem::linkToCrud('thematic', 'copy', Thematic::class);
yield MenuItem::linkToCrud('territory', 'copy', Territory::class);
yield MenuItem::linkToCrud('configuration', 'copy', Configuration::class);
);
yield MenuItem::linkToCrud('thematic', 'copy', Thematic::class)
->setPermission(self::ROLE_ADMIN);
yield MenuItem::linkToCrud('territory', 'copy', Territory::class)
->setPermission(self::ROLE_SUPER_ADMIN);
yield MenuItem::linkToCrud('configuration', 'copy', Configuration::class)
->setPermission(self::ROLE_SUPER_ADMIN);
yield MenuItem::linkToCrud('page', 'copy', Page::class)
->setPermission(self::ROLE_ADMIN);
}
}

+ 2
- 2
src/Controller/Admin/UserCrudController.php Zobrazit soubor

@@ -29,8 +29,8 @@ class UserCrudController extends AbstractUserCrudController
SessionInterface $session,
RequestStack $request,
EntityManager $em,
Environment $twig,
TranslatorAdmin $translatorAdmin,
Environment $twig,
UserPasswordEncoderInterface $passwordEncoder,
EntityManager $entityManager,
MailerInterface $mailerInterface
@@ -41,7 +41,7 @@ class UserCrudController extends AbstractUserCrudController
$this->entityManager = $entityManager;
$this->mailerInterface = $mailerInterface;

parent::__construct($session, $request, $em, $twig, $translatorAdmin);
parent::__construct($session, $request, $em, $translatorAdmin ,$twig);
}

public static function getEntityFqcn(): string

+ 4
- 0
src/Entity/CollectifData.php Zobrazit soubor

@@ -68,6 +68,10 @@ class CollectifData implements StatusInterface, EntityInterface
$this->projectsInspiring = new ArrayCollection();
}

public function __toString()
{
return $this->nbParticipant;
}
public function getId(): ?int
{
return $this->id;

+ 1
- 0
translations/admin.fr.yaml Zobrazit soubor

@@ -5,6 +5,7 @@ menu:
data_collectif: Formulaire collectif
data_collectif_validate: Données validées
data_collectif_waiting: Données en attente de validation
data_collectif_create: Formulaire collectif
territory: Territoires
thematic: Thématiques
configuration: Configuration question Intro

Načítá se…
Zrušit
Uložit