/**
  * @return ProductInterface
  */
 protected function getCurrentProduct()
 {
     $productId = $this->extractor->getDatagridParameter('product');
     if (!$productId) {
         throw new \LogicException('The current product type must be configured');
     }
     $product = $this->manager->find($productId);
     return $product;
 }
 function it_applies_a_filter_on_product_when_its_in_an_expected_group(FilterDatasourceAdapterInterface $datasource, $utility, ProductRepositoryInterface $repository, ProductQueryBuilderInterface $pqb, QueryBuilder $qb, RequestParametersExtractorInterface $extractor)
 {
     $extractor->getDatagridParameter('currentGroup')->willReturn(12);
     $datasource->getQueryBuilder()->willReturn($qb);
     $utility->getProductRepository()->willReturn($repository);
     $repository->getProductQueryBuilder($qb)->willReturn($pqb);
     $pqb->addFieldFilter('groups', 'IN', [12])->shouldBeCalled();
     $this->apply($datasource, ['type' => null, 'value' => 1]);
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function apply(FilterDatasourceAdapterInterface $ds, $data)
 {
     $data = $this->parseData($data);
     if (!$data) {
         return false;
     }
     $groupId = $this->extractor->getDatagridParameter('currentGroup');
     if (!$groupId) {
         throw new \LogicException('The current product group must be configured');
     }
     $value = [$groupId];
     $operator = $data['value'] === BooleanFilterType::TYPE_YES ? 'IN' : 'NOT IN';
     $this->util->applyFilter($ds, 'groups.id', $operator, $value);
     return true;
 }
 function it_applies_a_filter_on_product_when_its_in_an_expected_group(FilterDatasourceAdapterInterface $datasource, $utility, RequestParametersExtractorInterface $extractor)
 {
     $extractor->getDatagridParameter('currentGroup')->willReturn(12);
     $utility->applyFilter($datasource, 'groups.id', 'IN', [12])->shouldBeCalled();
     $this->apply($datasource, ['type' => null, 'value' => 1]);
 }