Selaa lähdekoodia

Controller : maj createEntity with Container

packProduct
Guillaume 3 vuotta sitten
vanhempi
commit
291662a50d
14 muutettua tiedostoa jossa 41 lisäystä ja 32 poistoa
  1. +2
    -2
      Controller/Config/TaxRateAdminController.php
  2. +2
    -2
      Controller/Config/UnitAdminController.php
  3. +2
    -2
      Controller/Credit/CreditHistoryAdminController.php
  4. +2
    -2
      Controller/Merchant/MerchantAdminController.php
  5. +3
    -2
      Controller/Newsletter/NewsletterAdminController.php
  6. +3
    -2
      Controller/PointSale/PointSaleAdminController.php
  7. +3
    -1
      Controller/Reminder/ReminderAdminController.php
  8. +3
    -2
      Controller/Section/OpeningAdminController.php
  9. +3
    -2
      Controller/Section/SectionAdminController.php
  10. +3
    -2
      Controller/Site/NewsAdminController.php
  11. +3
    -2
      Controller/Site/PageAdminController.php
  12. +3
    -2
      Controller/Ticket/TicketAdminController.php
  13. +3
    -2
      Controller/User/GroupUserAdminController.php
  14. +6
    -7
      Controller/User/UserMerchantAdminController.php

+ 2
- 2
Controller/Config/TaxRateAdminController.php Näytä tiedosto

@@ -5,6 +5,7 @@ namespace Lc\CaracoleBundle\Controller\Config;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Container\Config\TaxRateContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Factory\Config\TaxRateFactory;
use Lc\SovBundle\Controller\AbstractAdminController;
@@ -28,7 +29,6 @@ abstract class TaxRateAdminController extends AbstractAdminController

public function createEntity(string $entityFqcn)
{
$taxRateFactory = new TaxRateFactory();
return $taxRateFactory->create();
return $this->get(TaxRateContainer::class)->getFactory()->create();
}
}

+ 2
- 2
Controller/Config/UnitAdminController.php Näytä tiedosto

@@ -7,6 +7,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Container\Config\UnitContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Factory\Config\UnitFactory;
use Lc\SovBundle\Controller\AbstractAdminController;
@@ -29,7 +30,6 @@ abstract class UnitAdminController extends AbstractAdminController

public function createEntity(string $entityFqcn)
{
$unitFactory = new UnitFactory();
return $unitFactory->create();
return $this->get(UnitContainer::class)->getFactory()->create();
}
}

+ 2
- 2
Controller/Credit/CreditHistoryAdminController.php Näytä tiedosto

@@ -19,6 +19,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\MoneyField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
use Lc\CaracoleBundle\Container\Credit\CreditHistoryContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Factory\Credit\CreditHistoryFactory;
use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface;
@@ -52,8 +53,7 @@ abstract class CreditHistoryAdminController extends AbstractAdminController

public function createEntity(string $entityFqcn)
{
$creditHistoryFactory = new CreditHistoryFactory();
return $creditHistoryFactory->create();
return $this->get(CreditHistoryContainer::class)->getFactory()->create();
}

public function persistEntity(EntityManagerInterface $entityManager, $entityInstance): void

+ 2
- 2
Controller/Merchant/MerchantAdminController.php Näytä tiedosto

@@ -7,6 +7,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Container\Merchant\MerchantContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Factory\Merchant\MerchantFactory;
use Lc\CaracoleBundle\Field\Address\AddressField;
@@ -46,8 +47,7 @@ abstract class MerchantAdminController extends AbstractAdminController

public function createEntity(string $entityFqcn)
{
$merchantFactory = new MerchantFactory();
return $merchantFactory->create();
return $this->get(MerchantContainer::class)->getFactory()->create();
}

}

+ 3
- 2
Controller/Newsletter/NewsletterAdminController.php Näytä tiedosto

@@ -5,6 +5,7 @@ namespace Lc\CaracoleBundle\Controller\Newsletter;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Factory\Newsletter\NewsletterFactory;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\SovBundle\Container\Newsletter\NewsletterContainer;
use Lc\SovBundle\Controller\Newsletter\NewsletterAdminController as SovNewsletterAdminController;

abstract class NewsletterAdminController extends SovNewsletterAdminController
@@ -13,8 +14,8 @@ abstract class NewsletterAdminController extends SovNewsletterAdminController

public function createEntity(string $entityFqcn)
{
$newsletterFactory = new NewsletterFactory();
return $newsletterFactory
return $this->get(NewsletterContainer::class)
->getFactory()
->setMerchant($this->get(MerchantResolver::class)->getCurrent())
->create();
}

+ 3
- 2
Controller/PointSale/PointSaleAdminController.php Näytä tiedosto

@@ -5,6 +5,7 @@ namespace Lc\CaracoleBundle\Controller\PointSale;
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Container\PointSale\PointSaleContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Factory\PointSale\PointSaleFactory;
use Lc\CaracoleBundle\Field\Address\AddressField;
@@ -45,8 +46,8 @@ abstract class PointSaleAdminController extends AbstractAdminController

public function createEntity(string $entityFqcn)
{
$pointSaleFactory = new PointSaleFactory();
return $pointSaleFactory
return $this->get(PointSaleContainer::class)
->getFactory()
->setMerchant($this->get(MerchantResolver::class)->getCurrent())
->create();
}

+ 3
- 1
Controller/Reminder/ReminderAdminController.php Näytä tiedosto

@@ -7,6 +7,7 @@ use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Factory\Reminder\ReminderFactory;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\SovBundle\Container\Reminder\ReminderContainer;
use Lc\SovBundle\Controller\Reminder\ReminderAdminController as SovReminderAdminController;

class ReminderAdminController extends SovReminderAdminController
@@ -16,7 +17,8 @@ class ReminderAdminController extends SovReminderAdminController
public function createEntity(string $crudAction = null, string $crudControllerFqcn = null, int $entityId = null)
{
$reminderFactory = new ReminderFactory();
return $reminderFactory
return $this->get(ReminderContainer::class)
->getFactory()
->setMerchant($this->get(MerchantResolver::class)->getCurrent())
->setSection($this->get(SectionResolver::class)->getCurrent())
->create($crudAction, $crudControllerFqcn, $entityId);

+ 3
- 2
Controller/Section/OpeningAdminController.php Näytä tiedosto

@@ -6,6 +6,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TimeField;
use Lc\CaracoleBundle\Container\Section\OpeningContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Factory\Section\OpeningFactory;
use Lc\CaracoleBundle\Resolver\SectionResolver;
@@ -57,8 +58,8 @@ abstract class OpeningAdminController extends AbstractAdminController

public function createEntity(string $entityFqcn)
{
$openingFactory = new OpeningFactory();
return $openingFactory
return $this->get(OpeningContainer::class)
->getFactory()
->setSection($this->get(SectionResolver::class)->getCurrent())
->create();
}

+ 3
- 2
Controller/Section/SectionAdminController.php Näytä tiedosto

@@ -6,6 +6,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Container\Section\SectionContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Factory\Section\SectionFactory;
use Lc\CaracoleBundle\Form\Section\OpeningsFormType;
@@ -58,8 +59,8 @@ abstract class SectionAdminController extends AbstractAdminController

public function createEntity(string $entityFqcn)
{
$sectionFactory = new SectionFactory();
return $sectionFactory
return $this->get(SectionContainer::class)
->getFactory()
->setMerchant($this->get(MerchantResolver::class)->getCurrent())
->create();
}

+ 3
- 2
Controller/Site/NewsAdminController.php Näytä tiedosto

@@ -5,6 +5,7 @@ namespace Lc\CaracoleBundle\Controller\Site;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Factory\Site\NewsFactory;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\SovBundle\Container\Site\NewsContainer;
use Lc\SovBundle\Controller\Site\NewsAdminController as SovNewsAdminController;

abstract class NewsAdminController extends SovNewsAdminController
@@ -13,8 +14,8 @@ abstract class NewsAdminController extends SovNewsAdminController

public function createEntity(string $entityFqcn)
{
$newsFactory = new NewsFactory();
return $newsFactory
return $this->get(NewsContainer::class)
->getFactory()
->setMerchant($this->get(MerchantResolver::class)->getCurrent())
->create();
}

+ 3
- 2
Controller/Site/PageAdminController.php Näytä tiedosto

@@ -5,6 +5,7 @@ namespace Lc\CaracoleBundle\Controller\Site;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Factory\Site\PageFactory;
use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\SovBundle\Container\Site\PageContainer;
use Lc\SovBundle\Controller\Site\PageAdminController as SovPageAdminController;

abstract class PageAdminController extends SovPageAdminController
@@ -13,8 +14,8 @@ abstract class PageAdminController extends SovPageAdminController

public function createEntity(string $entityFqcn)
{
$pageFactory = new PageFactory();
return $pageFactory
return $this->get(PageContainer::class)
->getFactory()
->setSection($this->get(SectionResolver::class)->getCurrent())
->create();
}

+ 3
- 2
Controller/Ticket/TicketAdminController.php Näytä tiedosto

@@ -4,6 +4,7 @@ namespace Lc\CaracoleBundle\Controller\Ticket;

use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\SovBundle\Container\Ticket\TicketContainer;
use Lc\SovBundle\Controller\Ticket\TicketAdminController as SovTicketAdminController;
use Lc\CaracoleBundle\Factory\Ticket\TicketFactory;

@@ -13,8 +14,8 @@ class TicketAdminController extends SovTicketAdminController

public function createEntity(string $entityFqcn)
{
$ticketFactory = new TicketFactory();
return $ticketFactory
return $this->get(TicketContainer::class)
->getFactory()
->setMerchant($this->get(MerchantResolver::class)->getCurrent())
->create();
}

+ 3
- 2
Controller/User/GroupUserAdminController.php Näytä tiedosto

@@ -5,6 +5,7 @@ namespace Lc\CaracoleBundle\Controller\User;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Factory\User\GroupUserFactory;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\SovBundle\Container\User\GroupUserContainer;
use Lc\SovBundle\Controller\User\GroupUserAdminController as SovGroupUserAdminController;

abstract class GroupUserAdminController extends SovGroupUserAdminController
@@ -13,8 +14,8 @@ abstract class GroupUserAdminController extends SovGroupUserAdminController

public function createEntity(string $entityFqcn)
{
$groupUserFactory = new GroupUserFactory();
return $groupUserFactory
return $this->get(GroupUserContainer::class)
->getFactory()
->setMerchant($this->get(MerchantResolver::class)->getCurrent())
->create();
}

+ 6
- 7
Controller/User/UserMerchantAdminController.php Näytä tiedosto

@@ -23,6 +23,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Filter\BooleanFilter;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
use EasyCorp\Bundle\EasyAdminBundle\Security\Permission;
use Lc\CaracoleBundle\Container\User\UserMerchantContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Factory\User\UserFactory;
use Lc\CaracoleBundle\Factory\User\UserMerchantFactory;
@@ -62,7 +63,6 @@ abstract class UserMerchantAdminController extends AbstractAdminController
if ($entities) {
foreach ($entities as $entity) {
foreach ($entity->getActions() as $action) {

if ($action->getName() == 'credit_history') {
$url = $adminUrlGenerator
->setController($creditControllerFqcn)
@@ -114,8 +114,7 @@ abstract class UserMerchantAdminController extends AbstractAdminController
public function configureFilters(Filters $filters): Filters
{
return $filters
->add(BooleanFilter::new('active'))
;
->add(BooleanFilter::new('active'));
}

public function new(AdminContext $context): Response
@@ -123,10 +122,10 @@ abstract class UserMerchantAdminController extends AbstractAdminController
$entityManager = $this->get('em');
$userRepository = $entityManager->getRepository(UserInterface::class);
$merchantResolver = $this->get(MerchantResolver::class);
$userMerchantFactory = new UserMerchantFactory();
$userMerchant = $userMerchantFactory
->setMerchant($merchantResolver->getCurrent())
->create();
$userMerchant = $this->get(UserMerchantContainer::class)
->getFactory()
->setMerchant($merchantResolver->getCurrent())
->create();

$form = $this->createForm(UserMerchantFormType::class, $userMerchant);


Loading…
Peruuta
Tallenna