Beispiel #1
0
 /**
  * @covers BlockFilterApi::isDisplayable
  * @dataProvider filterProvider
  * @param array $filter
  * @param bool $expected
  */
 public function testIsDisplayable($filter, $expected)
 {
     $blockEntity = $this->getMockBuilder('Zikula\\BlocksModule\\Entity\\BlockEntity')->getMock();
     $blockEntity->method('getLanguage')->willReturn('en');
     $blockEntity->method('getFilters')->willReturn($filter);
     $this->assertEquals($expected, $this->api->isDisplayable($blockEntity));
 }
Beispiel #2
0
 /**
  * Get a filtered array of block entities that have been assigned to a block position.
  * @param $positionName
  * @return array
  */
 public function getBlocksByPosition($positionName)
 {
     if (empty($positionName)) {
         throw new \InvalidArgumentException('Name must not be empty.');
     }
     /** @var \Zikula\BlocksModule\Entity\BlockPositionEntity $position */
     $position = $this->blockPositionRepository->findByName($positionName);
     $blocks = [];
     if (empty($position)) {
         return $blocks;
     }
     foreach ($position->getPlacements() as $placement) {
         if ($placement->getBlock()->getActive() && $this->blockFilter->isDisplayable($placement->getBlock())) {
             $blocks[$placement->getBlock()->getBid()] = $placement->getBlock();
         }
     }
     return $blocks;
 }
Beispiel #3
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('attribute', 'Symfony\\Component\\Form\\Extension\\Core\\Type\\ChoiceType', ['choices' => $this->blockFilterApi->getFilterAttributeChoices(), 'choices_as_values' => true])->add('queryParameter', 'Symfony\\Component\\Form\\Extension\\Core\\Type\\TextType', ['required' => false])->add('comparator', 'Symfony\\Component\\Form\\Extension\\Core\\Type\\ChoiceType', ['choices' => ['==' => '==', '!=' => '!=', '>=' => '>=', '<=' => '<=', '>' => '>', '<' => '<', 'in_array' => 'in_array', '!in_array' => '!in_array'], 'choices_as_values' => true])->add('value', 'Symfony\\Component\\Form\\Extension\\Core\\Type\\TextType');
 }