Beispiel #1
0
 /**
  * @param BlockInterface $block
  */
 public function load(BlockInterface $block)
 {
     $gallery = $this->mediaManager->getRepository()->findByIds(json_decode($block->getValue()));
     if ($gallery) {
         $block->setGallery($gallery);
     }
 }
Beispiel #2
0
 /**
  * @param BlockInterface $block
  */
 public function load(BlockInterface $block)
 {
     $ids = json_decode($block->getValue());
     if (empty($ids) || !count($ids)) {
         return;
     }
     $gallery = $this->mediaManager->getRepository()->findByIds($ids);
     uasort($gallery, function ($a, $b) use($ids) {
         return array_search($a->getId(), $ids) > array_search($b->getId(), $ids);
     });
     if ($gallery) {
         $block->setGallery(new ArrayCollection($gallery));
     }
 }
Beispiel #3
0
 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['to_json' => false, 'property' => 'name', 'class' => $this->mediaManager->getClass(), 'query_builder' => function (EntityRepository $mediaRepository) {
         return $mediaRepository->createQueryBuilder('m')->add('orderBy', 'm.name ASC');
     }]);
 }