public function createEntity(string $entityFqcn) | public function createEntity(string $entityFqcn) | ||||
{ | { | ||||
if(method_exists($this, 'getEntityFactory')) { | if(method_exists($this, 'getEntityFactory')) { | ||||
$factoryClass = $this->getEntityFactory(); | |||||
return $this->getEntityFactory(); | |||||
$factory = new $factoryClass; | $factory = new $factoryClass; | ||||
return $factory->create(); | return $factory->create(); | ||||
} | } |
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; | use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | ||||
use Lc\SovBundle\Controller\AbstractAdminController; | use Lc\SovBundle\Controller\AbstractAdminController; | ||||
use Lc\SovBundle\Factory\Newsletter\NewsletterFactory; | |||||
use Lc\SovBundle\Field\BooleanField; | use Lc\SovBundle\Field\BooleanField; | ||||
use Lc\SovBundle\Field\CKEditorField; | use Lc\SovBundle\Field\CKEditorField; | ||||
use Lc\SovBundle\Field\StatusField; | use Lc\SovBundle\Field\StatusField; | ||||
); | ); | ||||
} | } | ||||
public function createEntity(string $entityFqcn) | |||||
{ | |||||
$factory = new NewsletterFactory(); | |||||
return $factory->create(); | |||||
} | |||||
} | } |
namespace Lc\SovBundle\Controller\Reminder; | namespace Lc\SovBundle\Controller\Reminder; | ||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||||
use Lc\CaracoleBundle\Resolver\SectionResolver; | |||||
use Lc\SovBundle\Factory\Reminder\ReminderFactory; | |||||
use Lc\SovBundle\Factory\Reminder\ReminderFactoryInterface; | use Lc\SovBundle\Factory\Reminder\ReminderFactoryInterface; | ||||
use Lc\SovBundle\Form\Reminder\ReminderAdminFormType; | use Lc\SovBundle\Form\Reminder\ReminderAdminFormType; | ||||
use Lc\SovBundle\Repository\Reminder\ReminderRepositoryQueryInterface; | use Lc\SovBundle\Repository\Reminder\ReminderRepositoryQueryInterface; | ||||
{ | { | ||||
protected EntityManagerInterface $entityManager; | protected EntityManagerInterface $entityManager; | ||||
protected ReminderFactoryInterface $reminderFactory; | |||||
protected ReminderRepositoryQueryInterface $reminderRepositoryQuery; | protected ReminderRepositoryQueryInterface $reminderRepositoryQuery; | ||||
protected FormFactoryInterface $formFactory; | protected FormFactoryInterface $formFactory; | ||||
protected UrlGeneratorInterface $urlGenerator; | protected UrlGeneratorInterface $urlGenerator; | ||||
public function __construct( | public function __construct( | ||||
EntityManagerInterface $entityManager, | EntityManagerInterface $entityManager, | ||||
ReminderFactoryInterface $reminderFactory, | |||||
ReminderRepositoryQueryInterface $reminderRepositoryQuery, | ReminderRepositoryQueryInterface $reminderRepositoryQuery, | ||||
FormFactoryInterface $formFactory, | FormFactoryInterface $formFactory, | ||||
UrlGeneratorInterface $urlGenerator, | UrlGeneratorInterface $urlGenerator, | ||||
ParameterBagInterface $parameterBag | ParameterBagInterface $parameterBag | ||||
) { | ) { | ||||
$this->entityManager = $entityManager; | $this->entityManager = $entityManager; | ||||
$this->reminderFactory = $reminderFactory; | |||||
$this->reminderRepositoryQuery = $reminderRepositoryQuery; | $this->reminderRepositoryQuery = $reminderRepositoryQuery; | ||||
$this->formFactory = $formFactory; | $this->formFactory = $formFactory; | ||||
$this->urlGenerator = $urlGenerator; | $this->urlGenerator = $urlGenerator; | ||||
public function createEntity(string $crudAction = null, string $crudControllerFqcn = null, int $entityId = null) | public function createEntity(string $crudAction = null, string $crudControllerFqcn = null, int $entityId = null) | ||||
{ | { | ||||
return $this->reminderFactory->create($crudAction, $crudControllerFqcn, $entityId); | |||||
$factory = new ReminderFactory(); | |||||
return $factory->create($crudAction, $crudControllerFqcn, $entityId); | |||||
} | } | ||||
} | } |
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | ||||
use Lc\SovBundle\Controller\AbstractAdminController; | use Lc\SovBundle\Controller\AbstractAdminController; | ||||
use Lc\SovBundle\Factory\Site\NewsFactory; | |||||
use Lc\SovBundle\Field\CKEditorField; | use Lc\SovBundle\Field\CKEditorField; | ||||
use Lc\SovBundle\Field\ImageManagerField; | |||||
use Lc\SovBundle\Field\StatusField; | use Lc\SovBundle\Field\StatusField; | ||||
abstract class NewsAdminController extends AbstractAdminController | abstract class NewsAdminController extends AbstractAdminController | ||||
); | ); | ||||
} | } | ||||
public function createEntity(string $entityFqcn) | |||||
{ | |||||
$factory = new NewsFactory(); | |||||
return $factory->create(); | |||||
} | |||||
} | } |
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | ||||
use Lc\SovBundle\Controller\AbstractAdminController; | use Lc\SovBundle\Controller\AbstractAdminController; | ||||
use Lc\SovBundle\Factory\Site\PageFactory; | |||||
use Lc\SovBundle\Field\CKEditorField; | use Lc\SovBundle\Field\CKEditorField; | ||||
use Lc\SovBundle\Field\StatusField; | use Lc\SovBundle\Field\StatusField; | ||||
); | ); | ||||
} | } | ||||
public function createEntity(string $entityFqcn) | |||||
{ | |||||
$factory = new PageFactory(); | |||||
return $factory->create(); | |||||
} | |||||
} | } |
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; | use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; | use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; | ||||
use Lc\SovBundle\Factory\Ticket\TicketFactory; | |||||
use Lc\SovBundle\Factory\Ticket\TicketFactoryInterface; | use Lc\SovBundle\Factory\Ticket\TicketFactoryInterface; | ||||
use Lc\SovBundle\Factory\Ticket\TicketMessageFactoryInterface; | use Lc\SovBundle\Factory\Ticket\TicketMessageFactoryInterface; | ||||
use Lc\SovBundle\Form\Ticket\TicketFormType; | use Lc\SovBundle\Form\Ticket\TicketFormType; | ||||
use Lc\SovBundle\Model\Ticket\TicketModel; | use Lc\SovBundle\Model\Ticket\TicketModel; | ||||
use Lc\SovBundle\Translation\TranslatorAdmin; | use Lc\SovBundle\Translation\TranslatorAdmin; | ||||
use Symfony\Component\HttpFoundation\JsonResponse; | use Symfony\Component\HttpFoundation\JsonResponse; | ||||
use Symfony\Component\HttpFoundation\Request; | |||||
class TicketAdminController extends AbstractAdminController | class TicketAdminController extends AbstractAdminController | ||||
{ | { | ||||
return TicketInterface::class; | return TicketInterface::class; | ||||
} | } | ||||
public function createEntity(string $entityFqcn) | |||||
{ | |||||
$factory = new TicketFactory(); | |||||
return $factory->create(); | |||||
} | |||||
public function configureAssets(Assets $assets): Assets | public function configureAssets(Assets $assets): Assets | ||||
{ | { | ||||
$assets = parent::configureAssets($assets); | $assets = parent::configureAssets($assets); |
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | ||||
use Lc\SovBundle\Controller\AbstractAdminController; | use Lc\SovBundle\Controller\AbstractAdminController; | ||||
use Lc\SovBundle\Factory\User\GroupUserFactory; | |||||
abstract class GroupUserAdminController extends AbstractAdminController | abstract class GroupUserAdminController extends AbstractAdminController | ||||
{ | { | ||||
TextField::new('title'), | TextField::new('title'), | ||||
TextField::new('devAlias'), | TextField::new('devAlias'), | ||||
]; | ]; | ||||
} | |||||
public function createEntity(string $entityFqcn) | |||||
{ | |||||
$factory = new GroupUserFactory(); | |||||
return $factory->create(); | |||||
} | } | ||||
} | } |
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; | ||||
use Lc\SovBundle\Factory\User\UserFactory; | |||||
use Lc\SovBundle\Translation\TranslatorAdmin; | use Lc\SovBundle\Translation\TranslatorAdmin; | ||||
use Symfony\Component\HttpFoundation\RequestStack; | use Symfony\Component\HttpFoundation\RequestStack; | ||||
use Symfony\Component\HttpFoundation\Session\SessionInterface; | use Symfony\Component\HttpFoundation\Session\SessionInterface; | ||||
abstract class UserAdminController extends AbstractAdminController | abstract class UserAdminController extends AbstractAdminController | ||||
{ | { | ||||
protected $rolesDefinition; | protected $rolesDefinition; | ||||
public function __construct( | public function __construct( | ||||
SessionInterface $session, | SessionInterface $session, | ||||
RequestStack $request, | RequestStack $request, | ||||
->setChoices($this->rolesDefinition->getRolesList()) | ->setChoices($this->rolesDefinition->getRolesList()) | ||||
]; | ]; | ||||
} | } | ||||
public function createEntity(string $entityFqcn) | |||||
{ | |||||
$factory = new UserFactory(); | |||||
return $factory->create(); | |||||
} | |||||
} | } |
class TicketFactory extends AbstractFactory implements TicketFactoryInterface | class TicketFactory extends AbstractFactory implements TicketFactoryInterface | ||||
{ | { | ||||
protected TicketMessageFactoryInterface $ticketMessageFactory; | |||||
public function __construct(TicketMessageFactoryInterface $ticketMessageFactory) | |||||
{ | |||||
$this->ticketMessageFactory = $ticketMessageFactory; | |||||
} | |||||
public function create(): TicketInterface | public function create(): TicketInterface | ||||
{ | { | ||||
$ticket = new Ticket(); | $ticket = new Ticket(); | ||||
$ticketMessage = $this->ticketMessageFactory->create() ; | |||||
$ticketMessageFactory = new TicketMessageFactory(); | |||||
$ticketMessage = $ticketMessageFactory->create() ; | |||||
$ticket->addTicketMessage($ticketMessage) ; | $ticket->addTicketMessage($ticketMessage) ; | ||||
return $ticket; | return $ticket; |