namespace Lc\CaracoleBundle\Controller\Reminder; | namespace Lc\CaracoleBundle\Controller\Reminder; | ||||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | use Lc\CaracoleBundle\Controller\AdminControllerTrait; | ||||
use Lc\SovBundle\Controller\Reminder\ReminderAdminController as SovReminderController; | |||||
use Lc\SovBundle\Controller\Reminder\ReminderAdminController as SovReminderAdminController; | |||||
abstract class ReminderAdminController extends SovReminderController | |||||
class ReminderAdminController extends SovReminderAdminController | |||||
{ | { | ||||
use AdminControllerTrait; | use AdminControllerTrait; | ||||
public function createEntity(string $crudAction = null, string $crudControllerFqcn = null, int $entityId = null) | |||||
{ | |||||
return $this->reminderFactory | |||||
->setMerchant($this->get('merchant_resolver')->getCurrent()) | |||||
->setSection($this->get('section_resolver')->getCurrent()) | |||||
->create($crudAction, $crudControllerFqcn, $entityId); | |||||
} | |||||
} | } |
<?php | |||||
namespace Lc\CaracoleBundle\Controller\Ticket; | |||||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||||
use Lc\SovBundle\Controller\Ticket\TicketAdminController as SovTicketAdminController; | |||||
class TicketAdminController extends SovTicketAdminController | |||||
{ | |||||
use AdminControllerTrait; | |||||
public function createEntityFromFactory() | |||||
{ | |||||
return $this->ticketFactory | |||||
->setMerchant($this->get('merchant_resolver')->getCurrent()) | |||||
->create(); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\CaracoleBundle\Factory; | |||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | |||||
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | |||||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||||
use Lc\CaracoleBundle\Resolver\SectionResolver; | |||||
use Lc\SovBundle\Factory\AbstractFactory as SovAbstractFactory; | |||||
trait FactoryTrait | |||||
{ | |||||
protected $merchantResolver; | |||||
protected $sectionResolver; | |||||
public function __construct( | |||||
EntityManagerInterface $em, | |||||
MerchantResolver $merchantResolver, | |||||
SectionResolver $sectionResolver | |||||
) { | |||||
$this->em = $em; | |||||
$this->merchantResolver = $merchantResolver; | |||||
$this->sectionResolver = $sectionResolver; | |||||
} | |||||
public function create($params = array()) | |||||
{ | |||||
$entityClass = $this->em->getEntityName($this->getEntityClass()); | |||||
$entity = new $entityClass; | |||||
if ($entity instanceof FilterMerchantInterface && !isset($params['merchant'])) { | |||||
$params['merchant'] = $this->merchantResolver->getCurrent(); | |||||
} | |||||
if ($entity instanceof FilterSectionInterface && !isset($params['section'])) { | |||||
$params['section'] = $this->sectionResolver->getCurrent(); | |||||
} | |||||
return parent::create($params); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\CaracoleBundle\Factory; | |||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||||
trait MerchantFactoryTrait | |||||
{ | |||||
public ?MerchantInterface $merchant = null; | |||||
public function setMerchant(MerchantInterface $merchant) | |||||
{ | |||||
$this->merchant = $merchant; | |||||
return $this; | |||||
} | |||||
} |
namespace Lc\CaracoleBundle\Factory\Reminder; | namespace Lc\CaracoleBundle\Factory\Reminder; | ||||
use Lc\CaracoleBundle\Factory\FactoryTrait; | |||||
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait; | |||||
use Lc\CaracoleBundle\Factory\SectionFactoryTrait; | |||||
use Lc\SovBundle\Factory\Reminder\ReminderFactory as SovReminderFactory; | use Lc\SovBundle\Factory\Reminder\ReminderFactory as SovReminderFactory; | ||||
use Lc\SovBundle\Model\Reminder\ReminderInterface; | |||||
class ReminderFactory extends SovReminderFactory | class ReminderFactory extends SovReminderFactory | ||||
{ | { | ||||
use FactoryTrait; | |||||
use MerchantFactoryTrait; | |||||
use SectionFactoryTrait; | |||||
public function create(string $crudAction = null, string $crudControllerFqcn = null, int $entityId = null): ReminderInterface | |||||
{ | |||||
$reminder = parent::create($crudAction, $crudControllerFqcn, $entityId); | |||||
$reminder->setMerchant($this->merchant) ; | |||||
$reminder->setSection($this->section) ; | |||||
return $reminder; | |||||
} | |||||
} | } |
<?php | |||||
namespace Lc\CaracoleBundle\Factory; | |||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||||
trait SectionFactoryTrait | |||||
{ | |||||
public ?SectionInterface $section = null; | |||||
public function setSection(SectionInterface $section) | |||||
{ | |||||
$this->section = $section; | |||||
return $this; | |||||
} | |||||
} |
namespace Lc\CaracoleBundle\Factory\Setting; | namespace Lc\CaracoleBundle\Factory\Setting; | ||||
use Lc\CaracoleBundle\Model\Setting\MerchantSettingInterface; | |||||
use App\Entity\Setting\MerchantSetting; | |||||
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait; | |||||
use Lc\SovBundle\Factory\AbstractFactory; | use Lc\SovBundle\Factory\AbstractFactory; | ||||
class MerchantSettingFactory extends AbstractFactory | class MerchantSettingFactory extends AbstractFactory | ||||
{ | { | ||||
public function getEntityClass() | |||||
use MerchantFactoryTrait; | |||||
public function create() | |||||
{ | { | ||||
return MerchantSettingInterface::class; | |||||
$merchantSetting = new MerchantSetting(); | |||||
$merchantSetting->setMerchant($this->merchant); | |||||
return $merchantSetting; | |||||
} | } | ||||
} | } |
namespace Lc\CaracoleBundle\Factory\Setting; | namespace Lc\CaracoleBundle\Factory\Setting; | ||||
use Lc\CaracoleBundle\Model\Setting\SectionSettingInterface; | |||||
use App\Entity\Setting\SectionSetting; | |||||
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait; | |||||
use Lc\SovBundle\Factory\AbstractFactory; | use Lc\SovBundle\Factory\AbstractFactory; | ||||
class SectionSettingFactory extends AbstractFactory | class SectionSettingFactory extends AbstractFactory | ||||
{ | { | ||||
public function getEntityClass() | |||||
use MerchantFactoryTrait; | |||||
public function create() | |||||
{ | { | ||||
return SectionSettingInterface::class; | |||||
$sectionSetting = new SectionSetting(); | |||||
$sectionSetting->setMerchant($this->merchant); | |||||
return $sectionSetting; | |||||
} | } | ||||
} | } |
namespace Lc\CaracoleBundle\Factory\Ticket; | namespace Lc\CaracoleBundle\Factory\Ticket; | ||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use Lc\CaracoleBundle\Factory\FactoryTrait; | |||||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||||
use Lc\CaracoleBundle\Resolver\SectionResolver; | |||||
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait; | |||||
use Lc\CaracoleBundle\Factory\SectionFactoryTrait; | |||||
use Lc\SovBundle\Factory\Ticket\TicketFactory as SovTicketFactory; | use Lc\SovBundle\Factory\Ticket\TicketFactory as SovTicketFactory; | ||||
use Lc\SovBundle\Factory\Ticket\TicketMessageFactory; | |||||
class TicketFactory extends SovTicketFactory | class TicketFactory extends SovTicketFactory | ||||
{ | { | ||||
// use FactoryTrait; | |||||
use MerchantFactoryTrait; | |||||
protected $merchantResolver; | |||||
protected $sectionResolver; | |||||
protected $ticketMessageFactory; | |||||
public function __construct( | |||||
EntityManagerInterface $em, | |||||
MerchantResolver $merchantResolver, | |||||
SectionResolver $sectionResolver, | |||||
TicketMessageFactory $ticketMessageFactory | |||||
) { | |||||
parent::__construct($em, $ticketMessageFactory); | |||||
$this->merchantResolver = $merchantResolver; | |||||
$this->sectionResolver = $sectionResolver; | |||||
} | |||||
public function create($params = array()) | |||||
public function create() | |||||
{ | { | ||||
if (!isset($params['merchant'])) { | |||||
$params['merchant'] = $this->merchantResolver->getCurrent(); | |||||
} | |||||
$ticket = parent::create(); | |||||
$ticket->setMerchant($this->merchant); | |||||
return parent::create($params); | |||||
return $ticket; | |||||
} | } | ||||
} | } |
namespace Lc\CaracoleBundle\Factory\User; | namespace Lc\CaracoleBundle\Factory\User; | ||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use App\Entity\User\UserMerchant; | |||||
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait; | |||||
use Lc\CaracoleBundle\Model\User\UserMerchantInterface; | use Lc\CaracoleBundle\Model\User\UserMerchantInterface; | ||||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||||
use Lc\SovBundle\Factory\AbstractFactory; | use Lc\SovBundle\Factory\AbstractFactory; | ||||
class UserMerchantFactory extends AbstractFactory | class UserMerchantFactory extends AbstractFactory | ||||
{ | { | ||||
protected $merchantResolver; | |||||
use MerchantFactoryTrait; | |||||
public function __construct(EntityManagerInterface $em, MerchantResolver $merchantResolver) | |||||
public function create(): UserMerchantInterface | |||||
{ | { | ||||
parent::__construct($em); | |||||
$this->merchantResolver = $merchantResolver; | |||||
} | |||||
public function getEntityClass() | |||||
{ | |||||
return UserMerchantInterface::class; | |||||
} | |||||
public function create($params = array()) | |||||
{ | |||||
if(!isset($params['merchant'])){ | |||||
$params['merchant'] = $this->merchantResolver->getCurrent(); | |||||
} | |||||
if(!isset($params['creditActive'])){ | |||||
$params['creditActive'] =false; | |||||
} | |||||
$userMerchant = new UserMerchant(); | |||||
if(!isset($params['active'])){ | |||||
$params['active'] = true; | |||||
} | |||||
$userMerchant->setMerchant($this->merchant); | |||||
return parent::create($params); // TODO: Change the autogenerated stub | |||||
return $userMerchant; | |||||
} | } | ||||
} | } |
/** | /** | ||||
* @ORM\Column(type="boolean") | * @ORM\Column(type="boolean") | ||||
*/ | */ | ||||
protected $creditActive; | |||||
protected $creditActive = false; | |||||
/** | /** | ||||
* @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface", mappedBy="userMerchant", orphanRemoval=true) | * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface", mappedBy="userMerchant", orphanRemoval=true) | ||||
/** | /** | ||||
* @ORM\Column(type="boolean") | * @ORM\Column(type="boolean") | ||||
*/ | */ | ||||
protected $active; | |||||
protected $active = true; | |||||
/** | /** | ||||
* @ORM\Column(type="json") | * @ORM\Column(type="json") |
carac_admin_setting_global: | carac_admin_setting_global: | ||||
path: /admin/setting/global2 | path: /admin/setting/global2 | ||||
controller: Lc\CaracoleBundle\Controller\Setting\SettingAdminController::manageGlobal | |||||
controller: Lc\CaracoleBundle\Controller\Setting\SettingAdminController::manageGlobal | |||||
carac_admin_reminder_render_modal: | |||||
path: /admin/caracole/reminder/modal | |||||
controller: Lc\CaracoleBundle\Controller\Reminder\ReminderAdminController::renderModal | |||||
carac_admin_reminder_new: | |||||
path: /admin/caracole/reminder/new | |||||
controller: Lc\CaracoleBundle\Controller\Reminder\ReminderAdminController::new |