|
- <?php
-
- namespace Lc\CaracoleBundle\Controller\Product;
-
- use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore;
- use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
- use Lc\CaracoleBundle\Container\Order\OrderShopContainer;
- use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer;
- use Lc\CaracoleBundle\Controller\AbstractAdminController;
- use Lc\CaracoleBundle\Resolver\SectionResolver;
- use Lc\SovBundle\Repository\RepositoryQueryInterface;
- use Symfony\Component\HttpFoundation\Response;
-
- abstract class ProductFamilyAdminController extends AbstractAdminController
- {
-
- public function getRepositoryQuery() :RepositoryQueryInterface
- {
- return $this->get(ProductFamilyContainer::class)->getRepositoryQuery();
- }
-
- public function createEntity(string $entityFqcn)
- {
- return $this->getProductFamilyContainer()
- ->getFactory()
- ->create($this->getMerchantCurrent());
- }
-
-
- public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore
- {
- $responseParameters = parent::configureResponseParameters($responseParameters);
-
- // affichage du filtre sur section
- $responseParameters->set('display_switch_section', true);
-
- return $responseParameters;
- }
-
- public function showSalesStatistic(AdminContext $context)
- {
- $productFamily = $context->getEntity()->getInstance();
-
- $currentSection = $this->get(SectionResolver::class)->getCurrent();
- $productsSalesStatistic = $this->get(OrderShopContainer::class)->getBuilder()->getProductsSalesStatistic($currentSection, $productFamily, 16);
- $parameters = array(
- 'productFamily' => $productFamily,
- 'productsSalesStatistic' => $productsSalesStatistic
- );
-
- //TODO flashMessages ???
- $response['flashMessages'] = [];//$this->utils->getFlashMessages();
- $response['data'] = $this->render('@LcCaracole/admin/product/modal/show_products_sales_statistic.html.twig', $parameters)->getContent();
- $response['statistics'] = $productsSalesStatistic;
- return new Response(json_encode($response));
- }
-
- }
|