Explorar el Código

Suppresion user: working on

feature/symfony6.1
Fabien Normand hace 2 años
padre
commit
3f1d0d9805
Se han modificado 8 ficheros con 129 adiciones y 13 borrados
  1. +8
    -0
      Container/File/FileContainer.php
  2. +24
    -0
      Controller/AbstractAdminController.php
  3. +2
    -11
      Controller/ControllerTrait.php
  4. +42
    -0
      Controller/User/UserAdminController.php
  5. +49
    -0
      Definition/ApplicationDefinition.php
  6. +3
    -1
      Factory/File/FileFactory.php
  7. +1
    -0
      Factory/Newsletter/NewsletterFactory.php
  8. +0
    -1
      Resources/assets/app/adminlte/form/form.js

+ 8
- 0
Container/File/FileContainer.php Ver fichero



namespace Lc\SovBundle\Container\File; namespace Lc\SovBundle\Container\File;


use App\Entity\File\File;
use Lc\SovBundle\Factory\File\FileFactory; use Lc\SovBundle\Factory\File\FileFactory;
use Lc\SovBundle\Model\File\FileInterface;
use Lc\SovBundle\Repository\File\FileRepositoryQuery; use Lc\SovBundle\Repository\File\FileRepositoryQuery;
use Lc\SovBundle\Repository\File\FileStore; use Lc\SovBundle\Repository\File\FileStore;


$this->store = $store; $this->store = $store;
} }


public static function getEntityFqcn()
{
return File::class;
}

public function getFactory(): FileFactory public function getFactory(): FileFactory
{ {
return $this->factory; return $this->factory;
{ {
return $this->store; return $this->store;
} }

} }

+ 24
- 0
Controller/AbstractAdminController.php Ver fichero

use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;


abstract class AbstractAdminController extends EaAbstractCrudController abstract class AbstractAdminController extends EaAbstractCrudController
{ {
return $this->createForm($class, $data, $options); 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;
}

} }



+ 2
- 11
Controller/ControllerTrait.php Ver fichero

use Lc\SovBundle\Container\Ticket\TicketMessageContainer; use Lc\SovBundle\Container\Ticket\TicketMessageContainer;
use Lc\SovBundle\Container\User\GroupUserContainer; use Lc\SovBundle\Container\User\GroupUserContainer;
use Lc\SovBundle\Container\User\UserContainer; use Lc\SovBundle\Container\User\UserContainer;
use Lc\SovBundle\Definition\ApplicationDefinition;
use Lc\SovBundle\Field\Filter\FilterManager; use Lc\SovBundle\Field\Filter\FilterManager;
use Lc\SovBundle\Generator\PdfGenerator; use Lc\SovBundle\Generator\PdfGenerator;
use Lc\SovBundle\Repository\EntityRepository; use Lc\SovBundle\Repository\EntityRepository;
{ {
return array_merge( return array_merge(
parent::getSubscribedServices(), parent::getSubscribedServices(),
ApplicationDefinition::getSubscribedContainerServices(),
[ [
Environment::class => Environment::class, Environment::class => Environment::class,
Security::class => Security::class, Security::class => Security::class,
AdminUrlGenerator::class => AdminUrlGenerator::class, AdminUrlGenerator::class => AdminUrlGenerator::class,
SettingSolver::class => SettingSolver::class, SettingSolver::class => SettingSolver::class,
ComponentContainer::class => ComponentContainer::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, EntityRepository::class => EntityRepository::class,
FileComponent::class => FileComponent::class, FileComponent::class => FileComponent::class,
] ]

+ 42
- 0
Controller/User/UserAdminController.php Ver fichero

use EasyCorp\Bundle\EasyAdminBundle\Config\Action; use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; 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\ChoiceField;
use EasyCorp\Bundle\EasyAdminBundle\Field\EmailField; use EasyCorp\Bundle\EasyAdminBundle\Field\EmailField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use EasyCorp\Bundle\EasyAdminBundle\Security\Permission;
use Lc\SovBundle\Container\User\UserContainer; use Lc\SovBundle\Container\User\UserContainer;
use Lc\SovBundle\Controller\AbstractAdminController; use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Definition\ActionDefinition; use Lc\SovBundle\Definition\ActionDefinition;
use Lc\SovBundle\Definition\ApplicationDefinition;
use Lc\SovBundle\Definition\RolesDefinition; use Lc\SovBundle\Definition\RolesDefinition;
use Lc\SovBundle\Definition\RolesDefinitionInterface; use Lc\SovBundle\Definition\RolesDefinitionInterface;
use Lc\SovBundle\Doctrine\EntityManager; use Lc\SovBundle\Doctrine\EntityManager;
{ {
return $this->get(UserContainer::class)->getFactory()->create(); 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();



}
} }

+ 49
- 0
Definition/ApplicationDefinition.php Ver fichero

<?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
- 1
Factory/File/FileFactory.php Ver fichero

namespace Lc\SovBundle\Factory\File; namespace Lc\SovBundle\Factory\File;


use App\Entity\File\File; use App\Entity\File\File;
use Lc\SovBundle\Container\File\FileContainer;
use Lc\SovBundle\Factory\AbstractFactory; use Lc\SovBundle\Factory\AbstractFactory;
use Lc\SovBundle\Model\File\FileInterface; use Lc\SovBundle\Model\File\FileInterface;


{ {
public function create(): FileInterface public function create(): FileInterface
{ {
$file = new File();
$class = FileContainer::getEntityFqcn();
$file = new $class;


return $file; return $file;
} }

+ 1
- 0
Factory/Newsletter/NewsletterFactory.php Ver fichero

namespace Lc\SovBundle\Factory\Newsletter; namespace Lc\SovBundle\Factory\Newsletter;


use App\Entity\Newsletter\Newsletter; use App\Entity\Newsletter\Newsletter;
use Lc\SovBundle\Definition\ApplicationDefinition;
use Lc\SovBundle\Factory\AbstractFactory; use Lc\SovBundle\Factory\AbstractFactory;
use Lc\SovBundle\Model\Newsletter\NewsletterInterface; use Lc\SovBundle\Model\Newsletter\NewsletterInterface;



+ 0
- 1
Resources/assets/app/adminlte/form/form.js Ver fichero

function checkForm() { function checkForm() {
$('form').addClass('form-sent'); $('form').addClass('form-sent');
//Panel vues js //Panel vues js
SovTools.log('ncnnc');
if ($('form').find('.tab-pane').length) { if ($('form').find('.tab-pane').length) {
$('form').find('.tab-pane').each(function (i, panel) { $('form').find('.tab-pane').each(function (i, panel) {
if ($(panel).find(':invalid').length) { if ($(panel).find(':invalid').length) {

Cargando…
Cancelar
Guardar