/** * * @param BlockInterface $block * * @return array */ public function getBlockChildren(BlockInterface $block) { $this->loadBlocks(); $children = array(); $cacheKey = $this->getCacheKey(); foreach ($this->blockCache[$cacheKey] as $member) { if ($member->getParent() == null) { continue; } if ($member->getParent()->getId() == $block->getId()) { // direct child array_push($children, $member); } else { if ($member->getOwner() && $member->getParent()->getId() == $member->getOwner()->getId() && $block instanceof BlockOwnerInterface) { array_push($children, $member); } } } return $children; }
/** * Returns available (root) versions for this block * * @param BlockInterface $block * * @return ArrayCollection */ public function getRootVersions(BlockInterface $block) { $rootId = $block instanceof BlockOwnerInterface ? $block->getId() : $block->getOwner()->getId(); /** @var BlockLogEntryRepository $repo */ $repo = $this->em->getRepository('OpiferContentBundle:BlockLogEntry'); $versions = $repo->findDistinctByRootId($rootId); return $versions; }
/** * @param BlockInterface $block */ public function load(BlockInterface $block) { $properties = $block->getProperties(); $opts = array(); if (isset($properties['responseType']) && $properties['responseType'] == 'redirect') { $opts['action'] = $this->router->generate('opifer_mailing_list_subscribe_block', ['id' => $block->getId()]); } $this->form = $this->formFactory->create(SubscribeType::class, $this->subscription, $opts); $this->form->handleRequest($this->request); if ($this->form->isValid()) { foreach ($this->getMailingLists($block) as $list) { $subscription = $this->subscriptionManager->findOrCreate($list, $this->subscription->getEmail()); $this->subscriptionManager->save($subscription); } $this->subscribed = true; } }
/** * @param BlockInterface $block * * @return null|string */ public function renderEsi(BlockInterface $block) { $reference = new ControllerReference('OpiferContentBundle:Frontend/Block:view', ['id' => $block->getId()], $this->getRequest()->query->all()); return $this->fragmentHandler->render($reference, 'esi'); }
public function addToClipboard(BlockInterface $block) { $this->blockIds[] = $block->getId(); $this->session->set(self::SESSION_KEY, $this->blockIds); }