|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329 |
- <?php
-
- namespace Lc\CaracoleBundle\Controller;
-
- use Lc\CaracoleBundle\Container\Address\AddressContainer;
- use Lc\CaracoleBundle\Container\Config\TaxRateContainer;
- use Lc\CaracoleBundle\Container\Config\UnitContainer;
- use Lc\CaracoleBundle\Container\Credit\CreditHistoryContainer;
- use Lc\CaracoleBundle\Container\File\DocumentContainer;
- use Lc\CaracoleBundle\Container\Merchant\MerchantContainer;
- use Lc\CaracoleBundle\Container\Order\OrderPaymentContainer;
- use Lc\CaracoleBundle\Container\Order\OrderProductContainer;
- use Lc\CaracoleBundle\Container\Order\OrderProductReductionCatalogContainer;
- use Lc\CaracoleBundle\Container\Order\OrderProductRefundContainer;
- use Lc\CaracoleBundle\Container\Order\OrderReductionCartContainer;
- use Lc\CaracoleBundle\Container\Order\OrderReductionCreditContainer;
- use Lc\CaracoleBundle\Container\Order\OrderRefundContainer;
- use Lc\CaracoleBundle\Container\Order\OrderShopContainer;
- use Lc\CaracoleBundle\Container\Order\OrderStatusContainer;
- use Lc\CaracoleBundle\Container\Order\OrderStatusHistoryContainer;
- use Lc\CaracoleBundle\Container\PointSale\PointSaleContainer;
- use Lc\CaracoleBundle\Container\PointSale\PointSaleSectionContainer;
- use Lc\CaracoleBundle\Container\Product\ProductCategoryContainer;
- use Lc\CaracoleBundle\Container\Product\ProductContainer;
- use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer;
- use Lc\CaracoleBundle\Container\Product\QualityLabelContainer;
- use Lc\CaracoleBundle\Container\Reduction\ReductionCartContainer;
- use Lc\CaracoleBundle\Container\Reduction\ReductionCatalogContainer;
- use Lc\CaracoleBundle\Container\Reduction\ReductionCreditContainer;
- use Lc\CaracoleBundle\Container\Section\OpeningContainer;
- use Lc\CaracoleBundle\Container\Section\SectionContainer;
- use Lc\CaracoleBundle\Container\Setting\MerchantSettingContainer;
- use Lc\CaracoleBundle\Container\Setting\SectionSettingContainer;
- use Lc\CaracoleBundle\Container\User\UserMerchantContainer;
- use Lc\CaracoleBundle\Container\User\UserPointSaleContainer;
- use Lc\CaracoleBundle\Container\User\VisitorContainer;
- use Lc\CaracoleBundle\Definition\ApplicationDefinition;
- use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
- use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
- use Lc\CaracoleBundle\Model\Section\SectionInterface;
- use Lc\CaracoleBundle\Model\User\UserMerchantInterface;
- use Lc\CaracoleBundle\Model\User\VisitorInterface;
- use Lc\CaracoleBundle\Notification\MailMailjetNotification;
- use Lc\CaracoleBundle\Resolver\MerchantResolver;
- use Lc\CaracoleBundle\Resolver\SectionResolver;
- use Lc\CaracoleBundle\Solver\Price\PriceSolver;
- use Lc\SovBundle\Model\User\UserInterface;
- use Lc\SovBundle\Solver\Setting\SettingSolver;
- use Symfony\Component\Security\Core\Security;
-
- trait ControllerTrait
- {
- public static function getSubscribedServices() :array
- {
- return array_merge(
- parent::getSubscribedServices(),
- ApplicationDefinition::getSubscribedContainerServices(),
- [
- MailMailjetNotification::class => MailMailjetNotification::class,
- PriceSolver::class => PriceSolver::class,
- MerchantResolver::class => MerchantResolver::class,
- SectionResolver::class => SectionResolver::class
- ]
- );
- }
-
- public function getMailMailjetNotification()
- {
- return $this->get(MailMailjetNotification::class);
- }
-
- public function getMerchantSettingCurrent(string $settingName)
- {
- return $this->getSettingValue($this->getMerchantCurrent(), $settingName);
- }
-
- public function getSectionSettingCurrent(string $settingName)
- {
- return $this->getSettingValue($this->getSectionCurrent(), $settingName);
- }
-
- public function getSettingSolver(): SettingSolver
- {
- return $this->get(SettingSolver::class);
- }
-
- public function getSettingValue($entity, $settingName)
- {
- return $this->getSettingSolver()->getSettingValue($entity, $settingName);
- }
-
- public function getUserCurrent(): ?UserInterface
- {
- return $this->get(Security::class)->getUser();
- }
-
- public function getVisitorCurrent(): ?VisitorInterface
- {
- return $this->getVisitorContainer()->getResolver()->getCurrent();
- }
-
- public function getMerchantCurrent(): MerchantInterface
- {
- return $this->get(MerchantResolver::class)->getCurrent();
- }
-
- public function getUserMerchantCurrent(): UserMerchantInterface
- {
- return $this->getUserMerchantContainer()->getBuilder()->createIfNotExist(
- $this->getUserCurrent(),
- $this->getMerchantCurrent()
- );
- }
-
- public function getMerchantUserCurrent(): MerchantInterface
- {
- return $this->get(MerchantResolver::class)->getMerchantUser($this->getUserCurrent());
- }
-
- public function getSectionCurrent(): ?SectionInterface
- {
- return $this->get(SectionResolver::class)->getCurrent();
- }
-
- public function getSectionCurrentDefault(): ?SectionInterface
- {
- return $this->get(SectionResolver::class)->getCurrent(true);
- }
-
- public function getSectionCurrentVisited(): ?SectionInterface
- {
- return $this->get(SectionResolver::class)->getCurrent(false, true);
- }
-
- public function isOutOfSection()
- {
- return $this->get(SectionResolver::class)->isOutOfSection();
- }
-
- public function getSectionCurrentSlug(): string
- {
- return $this->getSectionCurrent()->getSlug();
- }
-
- public function getCartCurrent(): OrderShopInterface
- {
- return $this->getOrderShopContainer()->getBuilder()->createIfNotExist(
- $this->getSectionCurrent(),
- $this->getUserCurrent(),
- $this->getVisitorCurrent(),
- true
- );
- }
-
- public function getCartCurrentVisited(): OrderShopInterface
- {
- return $this->getOrderShopContainer()->getBuilder()->createIfNotExist(
- $this->getSectionCurrentVisited(),
- $this->getUserCurrent(),
- $this->getVisitorCurrent(),
- true
- );
- }
-
- public function getPriceSolver(): PriceSolver
- {
- return $this->get(PriceSolver::class);
- }
-
- public function getOrderShopContainer(): OrderShopContainer
- {
- return $this->get(OrderShopContainer::class);
- }
-
- public function getAddressContainer(): AddressContainer
- {
- return $this->get(AddressContainer::class);
- }
-
- public function getTaxRateContainer(): TaxRateContainer
- {
- return $this->get(TaxRateContainer::class);
- }
-
- public function getUnitContainer(): UnitContainer
- {
- return $this->get(UnitContainer::class);
- }
-
- public function getCreditHistoryContainer(): CreditHistoryContainer
- {
- return $this->get(CreditHistoryContainer::class);
- }
-
- public function getDocumentContainer(): DocumentContainer
- {
- return $this->get(DocumentContainer::class);
- }
-
- public function getMerchantContainer(): MerchantContainer
- {
- return $this->get(MerchantContainer::class);
- }
-
- public function getOrderPaymentContainer(): OrderPaymentContainer
- {
- return $this->get(OrderPaymentContainer::class);
- }
-
- public function getOrderProductContainer(): OrderProductContainer
- {
- return $this->get(OrderProductContainer::class);
- }
-
- public function getOrderProductReductionCatalogContainer(): OrderProductReductionCatalogContainer
- {
- return $this->get(OrderProductReductionCatalogContainer::class);
- }
-
- public function getOrderProductRefundContainer(): OrderProductRefundContainer
- {
- return $this->get(OrderProductRefundContainer::class);
- }
-
- public function getOrderReductionCartContainer(): OrderReductionCartContainer
- {
- return $this->get(OrderReductionCartContainer::class);
- }
-
- public function getOrderReductionCreditContainer(): OrderReductionCreditContainer
- {
- return $this->get(OrderReductionCreditContainer::class);
- }
-
- public function getOrderRefundContainer(): OrderRefundContainer
- {
- return $this->get(OrderRefundContainer::class);
- }
-
- public function getOrderStatusContainer(): OrderStatusContainer
- {
- return $this->get(OrderStatusContainer::class);
- }
-
- public function getOrderStatusHistoryContainer(): OrderStatusHistoryContainer
- {
- return $this->get(OrderStatusHistoryContainer::class);
- }
-
- public function getPointSaleContainer(): PointSaleContainer
- {
- return $this->get(PointSaleContainer::class);
- }
-
- public function getProductCategoryContainer(): ProductCategoryContainer
- {
- return $this->get(ProductCategoryContainer::class);
- }
-
- public function getProductContainer(): ProductContainer
- {
- return $this->get(ProductContainer::class);
- }
-
- public function getProductFamilyContainer(): ProductFamilyContainer
- {
- return $this->get(ProductFamilyContainer::class);
- }
-
- public function getReductionCartContainer(): ReductionCartContainer
- {
- return $this->get(ReductionCartContainer::class);
- }
-
- public function getReductionCatalogContainer(): ReductionCatalogContainer
- {
- return $this->get(ReductionCatalogContainer::class);
- }
-
- public function getReductionCreditContainer(): ReductionCreditContainer
- {
- return $this->get(ReductionCreditContainer::class);
- }
-
- public function getOpeningContainer(): OpeningContainer
- {
- return $this->get(OpeningContainer::class);
- }
-
- public function getSectionContainer(): SectionContainer
- {
- return $this->get(SectionContainer::class);
- }
-
- public function getMerchantSettingContainer(): MerchantSettingContainer
- {
- return $this->get(MerchantSettingContainer::class);
- }
-
- public function getSectionSettingContainer(): SectionSettingContainer
- {
- return $this->get(SectionSettingContainer::class);
- }
-
- public function getUserMerchantContainer(): UserMerchantContainer
- {
- return $this->get(UserMerchantContainer::class);
- }
-
- public function getUserPointSaleContainer(): UserPointSaleContainer
- {
- return $this->get(UserPointSaleContainer::class);
- }
-
- public function getVisitorContainer(): VisitorContainer
- {
- return $this->get(VisitorContainer::class);
- }
-
- public function getQualityLabelContainer(): QualityLabelContainer
- {
- return $this->get(QualityLabelContainer::class);
- }
-
- public function getPointSaleSectionContainer(): PointSaleSectionContainer
- {
- return $this->get(PointSaleSectionContainer::class);
- }
- }
|