/** * @param BlockInterface $block */ public function load(BlockInterface $block) { $collection = $this->contentManager->getRepository()->findOrderedByIds(json_decode($block->getValue())); if ($collection) { $block->setCollection($collection); } }
/** * @param BlockInterface $block */ public function load(BlockInterface $block) { $collection = $this->contentManager->getRepository()->createQueryBuilder('c')->where('c.id IN (:ids)')->setParameter('ids', json_decode($block->getValue()))->getQuery()->getResult(); if ($collection) { $block->setCollection($collection); } }
/** * @param BlockInterface $block */ public function load(BlockInterface $block) { $properties = $block->getProperties(); $qb = $this->contentManager->getRepository()->createQueryBuilder('c'); if (isset($properties['order_by'])) { $direction = isset($properties['order_direction']) ? $properties['order_direction'] : 'ASC'; $qb->orderBy('c.' . $properties['order_by'], $direction); } $limit = isset($properties['limit']) ? $properties['limit'] : 10; $qb->setMaxResults($limit); $collection = $qb->getQuery()->getResult(); if ($collection) { $block->setCollection($collection); } }
/** * Load the collection if any conditions are defined * * @param BlockInterface $block */ protected function loadCollection(BlockInterface $block) { $properties = $block->getProperties(); $conditions = isset($properties['conditions']) ? $properties['conditions'] : '[]'; $conditions = $this->expressionEngine->deserialize($conditions); if (empty($conditions)) { return; } $qb = $this->expressionEngine->toQueryBuilder($conditions, $this->contentManager->getClass()); if (isset($properties['order_by'])) { $direction = isset($properties['order_direction']) ? $properties['order_direction'] : 'ASC'; $qb->orderBy('a.' . $properties['order_by'], $direction); } $limit = isset($properties['limit']) ? $properties['limit'] : 10; $qb->setMaxResults($limit); $collection = $qb->getQuery()->getResult(); if ($collection) { $block->setCollection($collection); } }