@@ -3,10 +3,17 @@ | |||
namespace Lc\CaracoleBundle\Controller\Reminder; | |||
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; | |||
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); | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
<?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(); | |||
} | |||
} |
@@ -1,43 +0,0 @@ | |||
<?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); | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
<?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; | |||
} | |||
} |
@@ -2,11 +2,24 @@ | |||
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\Model\Reminder\ReminderInterface; | |||
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; | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
<?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; | |||
} | |||
} |
@@ -2,13 +2,20 @@ | |||
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; | |||
class MerchantSettingFactory extends AbstractFactory | |||
{ | |||
public function getEntityClass() | |||
use MerchantFactoryTrait; | |||
public function create() | |||
{ | |||
return MerchantSettingInterface::class; | |||
$merchantSetting = new MerchantSetting(); | |||
$merchantSetting->setMerchant($this->merchant); | |||
return $merchantSetting; | |||
} | |||
} |
@@ -2,13 +2,20 @@ | |||
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; | |||
class SectionSettingFactory extends AbstractFactory | |||
{ | |||
public function getEntityClass() | |||
use MerchantFactoryTrait; | |||
public function create() | |||
{ | |||
return SectionSettingInterface::class; | |||
$sectionSetting = new SectionSetting(); | |||
$sectionSetting->setMerchant($this->merchant); | |||
return $sectionSetting; | |||
} | |||
} |
@@ -2,38 +2,20 @@ | |||
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\TicketMessageFactory; | |||
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; | |||
} | |||
} |
@@ -2,40 +2,21 @@ | |||
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\Resolver\MerchantResolver; | |||
use Lc\SovBundle\Factory\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; | |||
} | |||
} |
@@ -42,7 +42,7 @@ abstract class UserMerchantModel implements FilterMerchantInterface, EntityInter | |||
/** | |||
* @ORM\Column(type="boolean") | |||
*/ | |||
protected $creditActive; | |||
protected $creditActive = false; | |||
/** | |||
* @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface", mappedBy="userMerchant", orphanRemoval=true) | |||
@@ -52,7 +52,7 @@ abstract class UserMerchantModel implements FilterMerchantInterface, EntityInter | |||
/** | |||
* @ORM\Column(type="boolean") | |||
*/ | |||
protected $active; | |||
protected $active = true; | |||
/** | |||
* @ORM\Column(type="json") |
@@ -20,4 +20,12 @@ carac_admin_setting_section: | |||
carac_admin_setting_global: | |||
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 |