use Lc\CaracoleBundle\Repository\Section\SectionStore; | use Lc\CaracoleBundle\Repository\Section\SectionStore; | ||||
use Lc\CaracoleBundle\Solver\Price\PriceSolver; | use Lc\CaracoleBundle\Solver\Price\PriceSolver; | ||||
use Lc\CaracoleBundle\Solver\User\UserSolver; | use Lc\CaracoleBundle\Solver\User\UserSolver; | ||||
use Lc\SovBundle\Notification\MailMailjetNotification; | |||||
use Lc\CaracoleBundle\Notification\MailMailjetNotification; | |||||
class ReductionCreditBuilder | class ReductionCreditBuilder | ||||
{ | { |
namespace Lc\CaracoleBundle\Container\PointSale; | namespace Lc\CaracoleBundle\Container\PointSale; | ||||
use Lc\CaracoleBundle\Definition\Field\PointSale\PointSaleFieldDefinition; | |||||
use Lc\CaracoleBundle\Factory\PointSale\PointSaleFactory; | use Lc\CaracoleBundle\Factory\PointSale\PointSaleFactory; | ||||
use Lc\CaracoleBundle\Repository\PointSale\PointSaleRepositoryQuery; | use Lc\CaracoleBundle\Repository\PointSale\PointSaleRepositoryQuery; | ||||
use Lc\CaracoleBundle\Repository\PointSale\PointSaleStore; | use Lc\CaracoleBundle\Repository\PointSale\PointSaleStore; | ||||
{ | { | ||||
protected PointSaleFactory $factory; | protected PointSaleFactory $factory; | ||||
protected PointSaleSolver $solver; | protected PointSaleSolver $solver; | ||||
protected PointSaleFieldDefinition $fieldDefinition; | |||||
protected PointSaleRepositoryQuery $repositoryQuery; | protected PointSaleRepositoryQuery $repositoryQuery; | ||||
protected PointSaleStore $store; | protected PointSaleStore $store; | ||||
public function __construct( | public function __construct( | ||||
PointSaleFactory $factory, | PointSaleFactory $factory, | ||||
PointSaleSolver $solver, | PointSaleSolver $solver, | ||||
PointSaleFieldDefinition $fieldDefinition, | |||||
PointSaleRepositoryQuery $repositoryQuery, | PointSaleRepositoryQuery $repositoryQuery, | ||||
PointSaleStore $store | PointSaleStore $store | ||||
) { | ) { | ||||
$this->factory = $factory; | $this->factory = $factory; | ||||
$this->solver = $solver; | $this->solver = $solver; | ||||
$this->fieldDefinition = $fieldDefinition; | |||||
$this->repositoryQuery = $repositoryQuery; | $this->repositoryQuery = $repositoryQuery; | ||||
$this->store = $store; | $this->store = $store; | ||||
} | } | ||||
return $this->solver; | return $this->solver; | ||||
} | } | ||||
public function getFieldDefinition(): PointSaleFieldDefinition | |||||
{ | |||||
return $this->fieldDefinition; | |||||
} | |||||
public function getRepositoryQuery(): PointSaleRepositoryQuery | public function getRepositoryQuery(): PointSaleRepositoryQuery | ||||
{ | { | ||||
return $this->repositoryQuery; | return $this->repositoryQuery; |
<?php | |||||
namespace Lc\CaracoleBundle\Controller; | |||||
use Lc\SovBundle\Controller\AbstractAdminController as SovAbstractAdminController; | |||||
abstract class AbstractAdminController extends SovAbstractAdminController | |||||
{ | |||||
use AdminControllerTrait; | |||||
} |
trait AdminControllerTrait | trait AdminControllerTrait | ||||
{ | { | ||||
use ControllerTrait; | |||||
//TODO doit implementer ControllerTrait | //TODO doit implementer ControllerTrait | ||||
public static function getSubscribedServices() | |||||
/*public static function getSubscribedServices() | |||||
{ | { | ||||
return array_merge( | return array_merge( | ||||
parent::getSubscribedServices(), | parent::getSubscribedServices(), | ||||
UserPointSaleContainer::class => UserPointSaleContainer::class, | UserPointSaleContainer::class => UserPointSaleContainer::class, | ||||
VisitorContainer::class => VisitorContainer::class | VisitorContainer::class => VisitorContainer::class | ||||
]; | ]; | ||||
} | |||||
}*/ | |||||
public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore | public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore | ||||
{ | { | ||||
return $duplicateAction; | return $duplicateAction; | ||||
} | } | ||||
public function getCurrentSection() | |||||
{ | |||||
return $this->get(SectionResolver::class)->getCurrent(); | |||||
} | |||||
public function getCurrentMerchant() | |||||
{ | |||||
return $this->get(MerchantResolver::class)->getCurrent(); | |||||
} | |||||
public function getMerchantSettingCurrent(string $settingName) | |||||
{ | |||||
return $this->getSettingValue($this->getCurrentMerchant(), $settingName); | |||||
} | |||||
public function getSectionSettingCurrent(string $settingName) | |||||
{ | |||||
return $this->getSettingValue($this->getCurrentSection(), $settingName); | |||||
} | |||||
public function getSettingSolver(): SettingSolver | |||||
{ | |||||
return $this->get(SettingSolver::class); | |||||
} | |||||
public function getSettingValue($entity, $settingName) | |||||
{ | |||||
return $this->getSettingSolver()->getSettingValue($entity, $settingName); | |||||
} | |||||
} | } | ||||
public function getSectionSettingCurrent(string $settingName) | public function getSectionSettingCurrent(string $settingName) | ||||
{ | { | ||||
return $this->getSettingValue($this->getCurrentSection(), $settingName); | |||||
return $this->getSettingValue($this->getSectionCurrent(), $settingName); | |||||
} | } | ||||
public function getSettingSolver(): SettingSolver | public function getSettingSolver(): SettingSolver | ||||
return $this->getSettingSolver()->getSettingValue($entity, $settingName); | return $this->getSettingSolver()->getSettingValue($entity, $settingName); | ||||
} | } | ||||
public function getUserCurrent(): ?UserInterface | public function getUserCurrent(): ?UserInterface | ||||
{ | { | ||||
return $this->get(Security::class)->getUser(); | return $this->get(Security::class)->getUser(); |
namespace Lc\CaracoleBundle\Controller\PointSale; | namespace Lc\CaracoleBundle\Controller\PointSale; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\MoneyField; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||||
use Lc\CaracoleBundle\Container\PointSale\PointSaleContainer; | use Lc\CaracoleBundle\Container\PointSale\PointSaleContainer; | ||||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | use Lc\CaracoleBundle\Controller\AdminControllerTrait; | ||||
use Lc\CaracoleBundle\Factory\PointSale\PointSaleFactory; | |||||
use Lc\CaracoleBundle\Field\Address\AddressField; | |||||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||||
use Lc\SovBundle\Controller\AbstractAdminController; | use Lc\SovBundle\Controller\AbstractAdminController; | ||||
use Lc\SovBundle\Field\BooleanField; | |||||
use Lc\SovBundle\Field\StatusField; | |||||
use Lc\SovBundle\Field\ToggleField; | |||||
abstract class PointSaleAdminController extends AbstractAdminController | abstract class PointSaleAdminController extends AbstractAdminController | ||||
{ | { | ||||
public function configureFields(string $pageName): iterable | public function configureFields(string $pageName): iterable | ||||
{ | { | ||||
return array_merge( | |||||
[ | |||||
FormField::addPanel('general'), | |||||
IntegerField::new('id')->onlyOnIndex()->setSortable(true), | |||||
TextField::new('title')->setSortable(true), | |||||
MoneyField::new('orderAmountMin')->setCurrency('EUR')->setSortable(true), | |||||
NumberField::new('deliveryPrice') | |||||
->setCustomOption('appendHtml', '€') | |||||
->hideOnIndex(), | |||||
StatusField::new('status')->setSortable(true), | |||||
ToggleField::new('isPublic')->setSortable(true), | |||||
ToggleField::new('isDepository')->setSortable(true), | |||||
FormField::addPanel('address'), | |||||
AddressField::new('address') | |||||
->setRequired(true) | |||||
], | |||||
$this->getSeoPanel(), | |||||
$this->getConfPanel(), | |||||
); | |||||
return $this->getPointSaleContainer() | |||||
->getFieldDefinition() | |||||
->getFieldList($pageName); | |||||
} | } | ||||
public function createEntity(string $entityFqcn) | public function createEntity(string $entityFqcn) | ||||
{ | { | ||||
return $this->get(PointSaleContainer::class) | return $this->get(PointSaleContainer::class) | ||||
->getFactory() | |||||
->create($this->get(MerchantResolver::class)->getCurrent()); | |||||
->getFactory() | |||||
->create($this->getMerchantCurrent()); | |||||
} | } | ||||
} | } |
{ | { | ||||
use MerchantContextTrait; | use MerchantContextTrait; | ||||
public function configureFieldsIndex(): array | |||||
{ | |||||
return ['id']; | |||||
} | |||||
public function configurePanels(): array | public function configurePanels(): array | ||||
{ | { | ||||
return []; | return []; |
<?php | |||||
namespace Lc\CaracoleBundle\Definition\Field\PointSale; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||||
use Lc\CaracoleBundle\Field\Address\AddressField; | |||||
use Lc\SovBundle\Definition\Field\AbstractFieldDefinition; | |||||
use Lc\SovBundle\Field\StatusField; | |||||
class PointSaleFieldDefinition extends AbstractFieldDefinition | |||||
{ | |||||
public function configureFieldsIndex(): array | |||||
{ | |||||
return [ | |||||
'id', | |||||
'title', | |||||
'status' | |||||
]; | |||||
} | |||||
public function configurePanels(): array | |||||
{ | |||||
return [ | |||||
'main', | |||||
'address', | |||||
'seo', | |||||
'conf' | |||||
]; | |||||
} | |||||
public function configureFieldsPanelMain(): array | |||||
{ | |||||
return [ | |||||
'title', | |||||
'description', | |||||
'status' | |||||
]; | |||||
} | |||||
public function configureFieldsPanelAddress(): array | |||||
{ | |||||
return ['address']; | |||||
} | |||||
public function configureFields(): array | |||||
{ | |||||
return [ | |||||
'id' => IntegerField::new('id')->setSortable(true)->onlyOnIndex(), | |||||
'title' => TextField::new('title')->setSortable(true), | |||||
'description' => TextEditorField::new('description'), | |||||
'status' => StatusField::new('status')->setSortable(true), | |||||
'address' => AddressField::new('address') | |||||
->setRequired(true), | |||||
]; | |||||
} | |||||
} |
class MerchantSettingsFormType extends AbstractType | class MerchantSettingsFormType extends AbstractType | ||||
{ | { | ||||
protected $em; | |||||
protected $translatorAdmin; | |||||
protected EntityManagerInterface $em; | |||||
protected TranslatorAdmin $translatorAdmin; | |||||
public function __construct(EntityManagerInterface $em, TranslatorAdmin $translatorAdmin) | public function __construct(EntityManagerInterface $em, TranslatorAdmin $translatorAdmin) | ||||
{ | { |
<?php | |||||
namespace Lc\CaracoleBundle\Notification; | |||||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||||
use Lc\SovBundle\Notification\MailMailjetNotification as SovMailMailjetNotification; | |||||
use Lc\CaracoleBundle\Definition\MerchantSettingDefinition; | |||||
use Lc\SovBundle\Repository\Site\SiteStore; | |||||
use Lc\SovBundle\Solver\Setting\SettingSolver; | |||||
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport; | |||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | |||||
use Twig\Environment; | |||||
class MailMailjetNotification extends SovMailMailjetNotification | |||||
{ | |||||
protected MerchantResolver $merchantResolver; | |||||
public function __construct( | |||||
MailjetTransport $mailjetTransport, | |||||
Environment $templating, | |||||
ParameterBagInterface $parameterBag, | |||||
SettingSolver $settingSolver, | |||||
MerchantResolver $merchantResolver, | |||||
SiteStore $siteStore | |||||
) { | |||||
parent::__construct($mailjetTransport, $templating, $parameterBag, $settingSolver, $siteStore); | |||||
$this->merchantResolver = $merchantResolver; | |||||
} | |||||
public function send($params = []) | |||||
{ | |||||
$merchantCurrent = $this->merchantResolver->getCurrent(); | |||||
$merchantConfigEmailFrom = $this->settingSolver->getSettingValue( | |||||
$merchantCurrent, | |||||
MerchantSettingDefinition::SETTING_EMAIL_FROM | |||||
); | |||||
$emailFrom = (isset($params[self::FROM_EMAIL]) && $params[self::FROM_EMAIL] && strlen( | |||||
$params[self::FROM_EMAIL] | |||||
)) ? $params[self::FROM_EMAIL] : $merchantConfigEmailFrom; | |||||
$merchantConfigEmailFromName = $this->settingSolver->getSettingValue( | |||||
$merchantCurrent, | |||||
MerchantSettingDefinition::SETTING_EMAIL_FROM_NAME | |||||
); | |||||
$emailFromName = isset($params[self::FROM_NAME]) ?? $merchantConfigEmailFromName; | |||||
$merchantConfigEmailSubjectPrefix = $this->settingSolver->getSettingValue( | |||||
$merchantCurrent, | |||||
MerchantSettingDefinition::SETTING_EMAIL_SUBJECT_PREFIX | |||||
); | |||||
$emailSubjectPrefix = isset($params[self::SUBJECT_PREFIX]) ?? $merchantConfigEmailSubjectPrefix; | |||||
if ($emailSubjectPrefix && strlen($emailSubjectPrefix)) { | |||||
$emailSubjectPrefix .= ' '; | |||||
} | |||||
return parent::send( | |||||
array_merge($params, [ | |||||
self::FROM_EMAIL => $emailFrom, | |||||
self::FROM_NAME => $emailFromName, | |||||
self::SUBJECT_PREFIX => $emailSubjectPrefix | |||||
]) | |||||
); | |||||
} | |||||
} |
entity: | entity: | ||||
default: | default: | ||||
panels: | panels: | ||||
main: Général | |||||
address: Adresse | address: Adresse | ||||
conf: Configuration | |||||
fields: | fields: | ||||
property: Caractéristiques | property: Caractéristiques | ||||
propertyValue : Valeurs | propertyValue : Valeurs | ||||
label_plurial: Points de vente | label_plurial: Points de vente | ||||
fields: | fields: | ||||
orderAmountMin: Montant minimum de commande | orderAmountMin: Montant minimum de commande | ||||
isPublic: Public | |||||
isPublic: Publique | |||||
isDepository: Dépôt | isDepository: Dépôt | ||||
deliveryPrice: Montant de la livraison | |||||
Address: | Address: | ||||
fields: | fields: |