@@ -2,7 +2,9 @@ | |||
namespace Lc\SovBundle\Container\File; | |||
use App\Entity\File\File; | |||
use Lc\SovBundle\Factory\File\FileFactory; | |||
use Lc\SovBundle\Model\File\FileInterface; | |||
use Lc\SovBundle\Repository\File\FileRepositoryQuery; | |||
use Lc\SovBundle\Repository\File\FileStore; | |||
@@ -22,6 +24,11 @@ class FileContainer | |||
$this->store = $store; | |||
} | |||
public static function getEntityFqcn() | |||
{ | |||
return File::class; | |||
} | |||
public function getFactory(): FileFactory | |||
{ | |||
return $this->factory; | |||
@@ -36,4 +43,5 @@ class FileContainer | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -61,6 +61,7 @@ use Symfony\Component\Form\Extension\Core\Type\TextType; | |||
use Symfony\Component\Form\FormInterface; | |||
use Symfony\Component\HttpFoundation\JsonResponse; | |||
use Symfony\Component\HttpFoundation\RequestStack; | |||
use Symfony\Component\HttpFoundation\Response; | |||
abstract class AbstractAdminController extends EaAbstractCrudController | |||
{ | |||
@@ -840,5 +841,28 @@ abstract class AbstractAdminController extends EaAbstractCrudController | |||
return $this->createForm($class, $data, $options); | |||
} | |||
public function eaBeforeCrudActionEventDelete(AdminContext $context): ?Response | |||
{ | |||
$event = new BeforeCrudActionEvent($context); | |||
$this->container->get('event_dispatcher')->dispatch($event); | |||
if ($event->isPropagationStopped()) { | |||
return $event->getResponse(); | |||
} | |||
if (!$this->isGranted(Permission::EA_EXECUTE_ACTION, ['action' => Action::DELETE, 'entity' => $context->getEntity()])) { | |||
throw new ForbiddenActionException($context); | |||
} | |||
if (!$context->getEntity()->isAccessible()) { | |||
throw new InsufficientEntityPermissionException($context); | |||
} | |||
$csrfToken = $context->getRequest()->request->get('token'); | |||
if (!$this->isCsrfTokenValid('ea-delete', $csrfToken)) { | |||
return $this->redirectToRoute($context->getDashboardRouteName()); | |||
} | |||
return null; | |||
} | |||
} | |||
@@ -18,6 +18,7 @@ use Lc\SovBundle\Container\Ticket\TicketContainer; | |||
use Lc\SovBundle\Container\Ticket\TicketMessageContainer; | |||
use Lc\SovBundle\Container\User\GroupUserContainer; | |||
use Lc\SovBundle\Container\User\UserContainer; | |||
use Lc\SovBundle\Definition\ApplicationDefinition; | |||
use Lc\SovBundle\Field\Filter\FilterManager; | |||
use Lc\SovBundle\Generator\PdfGenerator; | |||
use Lc\SovBundle\Repository\EntityRepository; | |||
@@ -46,6 +47,7 @@ trait ControllerTrait | |||
{ | |||
return array_merge( | |||
parent::getSubscribedServices(), | |||
ApplicationDefinition::getSubscribedContainerServices(), | |||
[ | |||
Environment::class => Environment::class, | |||
Security::class => Security::class, | |||
@@ -66,17 +68,6 @@ trait ControllerTrait | |||
AdminUrlGenerator::class => AdminUrlGenerator::class, | |||
SettingSolver::class => SettingSolver::class, | |||
ComponentContainer::class => ComponentContainer::class, | |||
FileContainer::class => FileContainer::class, | |||
NewsletterContainer::class => NewsletterContainer::class, | |||
ReminderContainer::class => ReminderContainer::class, | |||
NewsContainer::class => NewsContainer::class, | |||
PageContainer::class => PageContainer::class, | |||
SiteContainer::class => SiteContainer::class, | |||
TicketContainer::class => TicketContainer::class, | |||
TicketMessageContainer::class => TicketMessageContainer::class, | |||
GroupUserContainer::class => GroupUserContainer::class, | |||
UserContainer::class => UserContainer::class, | |||
SiteSettingContainer::class => SiteSettingContainer::class, | |||
EntityRepository::class => EntityRepository::class, | |||
FileComponent::class => FileComponent::class, | |||
] |
@@ -6,12 +6,19 @@ use EasyCorp\Bundle\EasyAdminBundle\Collection\EntityCollection; | |||
use EasyCorp\Bundle\EasyAdminBundle\Config\Action; | |||
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; | |||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | |||
use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; | |||
use EasyCorp\Bundle\EasyAdminBundle\Event\BeforeCrudActionEvent; | |||
use EasyCorp\Bundle\EasyAdminBundle\Event\BeforeEntityDeletedEvent; | |||
use EasyCorp\Bundle\EasyAdminBundle\Exception\ForbiddenActionException; | |||
use EasyCorp\Bundle\EasyAdminBundle\Exception\InsufficientEntityPermissionException; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\EmailField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; | |||
use Lc\SovBundle\Container\User\UserContainer; | |||
use Lc\SovBundle\Controller\AbstractAdminController; | |||
use Lc\SovBundle\Definition\ActionDefinition; | |||
use Lc\SovBundle\Definition\ApplicationDefinition; | |||
use Lc\SovBundle\Definition\RolesDefinition; | |||
use Lc\SovBundle\Definition\RolesDefinitionInterface; | |||
use Lc\SovBundle\Doctrine\EntityManager; | |||
@@ -76,4 +83,39 @@ abstract class UserAdminController extends AbstractAdminController | |||
{ | |||
return $this->get(UserContainer::class)->getFactory()->create(); | |||
} | |||
public function delete(AdminContext $context) | |||
{ | |||
$eaBeforeCrudActionEventDelete = $this->eaBeforeCrudActionEventDelete($context); | |||
if(!is_null($eaBeforeCrudActionEventDelete)){ | |||
return $eaBeforeCrudActionEventDelete; | |||
} | |||
$entityInstance = $context->getEntity()->getInstance(); | |||
$event = new BeforeEntityDeletedEvent($entityInstance); | |||
$this->container->get('event_dispatcher')->dispatch($event); | |||
if ($event->isPropagationStopped()) { | |||
return $event->getResponse(); | |||
} | |||
$entityInstance = $event->getEntityInstance(); | |||
ApplicationDefinition::getSubscribedContainerServices(); | |||
$metas = $this->getEntityManager()->getMetadataFactory()->getAllMetadata(); | |||
foreach ($metas as $meta) { | |||
$entities[] = $meta->getName(); | |||
} | |||
foreach ($entities as $entity){ | |||
dump($entity); | |||
dump($context->getCrudControllers()); | |||
} | |||
die(); | |||
} | |||
} |
@@ -0,0 +1,49 @@ | |||
<?php | |||
namespace Lc\SovBundle\Definition; | |||
use Lc\SovBundle\Container\File\FileContainer; | |||
use Lc\SovBundle\Container\Newsletter\NewsletterContainer; | |||
use Lc\SovBundle\Container\Reminder\ReminderContainer; | |||
use Lc\SovBundle\Container\Setting\SiteSettingContainer; | |||
use Lc\SovBundle\Container\Site\NewsContainer; | |||
use Lc\SovBundle\Container\Site\PageContainer; | |||
use Lc\SovBundle\Container\Site\SiteContainer; | |||
use Lc\SovBundle\Container\Ticket\TicketContainer; | |||
use Lc\SovBundle\Container\Ticket\TicketMessageContainer; | |||
use Lc\SovBundle\Container\User\GroupUserContainer; | |||
use Lc\SovBundle\Container\User\UserContainer; | |||
class ApplicationDefinition | |||
{ | |||
public static function getContainerList(): array | |||
{ | |||
return [ | |||
FileContainer::class, | |||
NewsletterContainer::class, | |||
ReminderContainer::class, | |||
NewsContainer::class, | |||
PageContainer::class, | |||
SiteContainer::class, | |||
TicketContainer::class, | |||
TicketMessageContainer::class, | |||
GroupUserContainer::class, | |||
UserContainer::class, | |||
SiteSettingContainer::class | |||
]; | |||
} | |||
public static function getSubscribedContainerServices(): array | |||
{ | |||
$array = []; | |||
foreach (self::$containers as $container) { | |||
$array[$container] = $container; | |||
} | |||
return $array; | |||
} | |||
} |
@@ -3,6 +3,7 @@ | |||
namespace Lc\SovBundle\Factory\File; | |||
use App\Entity\File\File; | |||
use Lc\SovBundle\Container\File\FileContainer; | |||
use Lc\SovBundle\Factory\AbstractFactory; | |||
use Lc\SovBundle\Model\File\FileInterface; | |||
@@ -10,7 +11,8 @@ class FileFactory extends AbstractFactory | |||
{ | |||
public function create(): FileInterface | |||
{ | |||
$file = new File(); | |||
$class = FileContainer::getEntityFqcn(); | |||
$file = new $class; | |||
return $file; | |||
} |
@@ -3,6 +3,7 @@ | |||
namespace Lc\SovBundle\Factory\Newsletter; | |||
use App\Entity\Newsletter\Newsletter; | |||
use Lc\SovBundle\Definition\ApplicationDefinition; | |||
use Lc\SovBundle\Factory\AbstractFactory; | |||
use Lc\SovBundle\Model\Newsletter\NewsletterInterface; | |||
@@ -3,7 +3,6 @@ | |||
function checkForm() { | |||
$('form').addClass('form-sent'); | |||
//Panel vues js | |||
SovTools.log('ncnnc'); | |||
if ($('form').find('.tab-pane').length) { | |||
$('form').find('.tab-pane').each(function (i, panel) { | |||
if ($(panel).find(':invalid').length) { |