@param ReadBlockInterface $block

@return null|DisplayBlockInterface
10216
protected function getStrategy(ReadBlockInterface $block)
    {
        if (isset($this->cachedStrategies[$block->getId()])) {
            return $this->cachedStrategies[$block->getId()];
        }

        foreach ($this->strategies as $strategy) {
            if ($strategy->support($block)) {
                if ($block->getId()) {
                    $this->cachedStrategies[$block->getId()] = $strategy;
                }

                return $strategy;
            }
        }

        return null;
    }
70984
public function show(ReadBlockInterface $block)
    {
        $request = $this->requestStack->getCurrentRequest();

        $data = $request->get('elastica_search');
        $searchData = array();
        if (is_array($data) && array_key_exists('search', $data) && null !== $data['search']) {
            $searchParameter = $data['search'];

            $index = $this->client->getIndex($this->indexName);

            $qb = new QueryBuilder();

            $search = new Search($this->client);
            $search->addIndex($index);
            $search->setQuery($qb->query()->filtered(
                $qb->query()->query_string($searchParameter),
                $qb->filter()->bool()->addMust(
                    $qb->filter()->term(array('language' => $request->getLocale()))
                )
            ));
            $searchData = $search->search(null, array('limit' => $block->getAttribute('searchLimit')));
        }

        return $this->render('OpenOrchestraElasticaFrontBundle:Block/List:show.html.twig', array(
            'searchData' => $searchData,
            'id' => $block->getId(),
            'class' => $block->getStyle(),
        ));
    }
302751
public function show(ReadBlockInterface $block)
    {
        $htmlContent = $block->getAttribute('htmlContent');
        $this->parser->parse($htmlContent);
        $htmlContent = $this->parser->getAsHTML();

        return $this->render(
            'OpenOrchestraDisplayBundle:Block/TinyMCEWysiwyg:show.html.twig',
            array(
                'htmlContent' => $htmlContent,
                'id' => $block->getId(),
                'class' => $block->getStyle(),
            )
        );
    }
683729
public function setBlock(BlockInterface $block)
    {
        $this->subject->setBlock($block);
        $this->block = $block;

        return $this;
    }
1236273
public function show(ReadBlockInterface $block)
    {
        $currentRequest = $this->requestStack->getCurrentRequest();

        $routeAttributes = array_merge(
            $currentRequest->get('_route_params'),
            array(
                'previous' => $currentRequest->get('currentRouteName'),
                'aliasId'  => $currentRequest->get('aliasId'),
            )
        );

        $form = $this->formFactory->create(
            ContactType::class,
            null,
            array(
                'method' => 'POST',
                'action' => $this->urlGenerator->generate(
                    'open_orchestra_front_block',
                    $routeAttributes
                )
            )
        );

        $form->handleRequest($currentRequest);

        if ($form->isValid()) {
            $recipient = $block->getAttribute("recipient");
            $signature = $block->getAttribute("signature");
            $formData = $form->getData();
            //send alert message to webmaster
            $messageToAdmin = \Swift_Message::newInstance()
                ->setSubject($formData['subject'])
                ->setFrom($formData['email'])
                ->setTo($recipient)
                ->setBody(
                    $this->renderView(
                        'OpenOrchestraDisplayBundle:Block/Email:show_admin.txt.twig',
                        array(
                            'name' => $formData['name'],
                            'message' => $formData['message'],
                            'mail' => $formData['email'],
                        )
                    )
                );
            $event = new MailerEvent($messageToAdmin);
            $this->dispatcher->dispatch(MailerEvents::SEND_MAIL, $event);

            //send confirm e-mail for the user
            $messageToUser = \Swift_Message::newInstance()
                ->setSubject('open_orchestra_display.contact.contact_received')
                ->setFrom($recipient)
                ->setTo($formData['email'])
                ->setBody(
                    $this->renderView(
                        'OpenOrchestraDisplayBundle:Block/Email:show_user.txt.twig',
                        array('signature' => $signature)
                    )
                );
            $event = new MailerEvent($messageToUser);
            $this->dispatcher->dispatch(MailerEvents::SEND_MAIL, $event);
        }

        return $this->render('OpenOrchestraDisplayBundle:Block/Contact:show.html.twig', array(
            'form' => $form->createView(),
            'id' => $block->getId(),
            'class' => $block->getStyle(),
        ));
    }
663972
public function show(ReadBlockInterface $block)
    {
        $linkUrl = null;
        $nodeToLink = $block->getAttribute('nodeToLink');

        if (!empty($nodeToLink)) {
            $language = $this->currentSiteManager->getSiteLanguage();
            $siteId = $this->currentSiteManager->getSiteId();
            $linkUrl = $this->nodeRepository->findOnePublished($nodeToLink, $language, $siteId);
        }

        $parameters = array(
            'picture' => $block->getAttribute('picture'),
            'linkUrl' => $linkUrl,
            'id' => $block->getId(),
            'class' => $block->getStyle(),
        );

        return $this->render($this->template, $parameters);
    }
1119628
protected function getCurrentBlockProperty(Model\BlockInterface $block, $property, $default)
    {
        $layout = $block->getLayout();
        $currentSize = $default;

        foreach ($this->resolveLowerDevices() as $d) {
            if (isset($layout[$d]) && isset($layout[$d][$property])) {
                $currentSize = $layout[$d][$property];
                break;
            }
        }

        return $currentSize;
    }
1344979
public function moveRight(Model\BlockInterface $block)
    {
        $sibling = $this->editor->getRepository()->findSiblingBlock($block, true);
        if (null === $sibling) {
            throw new InvalidOperationException(
                "The block can't be moved to the right as no sibling block has been found."
            );
        }

        $block->setPosition($block->getPosition() + 1);
        $sibling->setPosition($sibling->getPosition() - 1);

        $this->sortChildrenByPosition($block->getRow(), 'blocks');

        return $sibling;
    }
1033703
public function get($block = false)
    {
        if ($this->block != $block) {
            $this->pipe->setBlock($block);
            $this->block = $block;
        }
        $len = $this->pipe->read(4);
        if ($len === false) {
            throw new \RuntimeException('read pipe failed');
        }

        if (strlen($len) === 0) {
            return null;
        }
        $len = unpack('N', $len);
        if (empty($len) || !array_key_exists(1, $len) || empty($len[1])) {
            throw new \RuntimeException('data protocol error');
        }
        $len = intval($len[1]);

        $value = '';
        while (true) {
            $temp = $this->pipe->read($len);
            if (strlen($temp) == $len) {
                return $temp;
            }
            $value .= $temp;
            $len -= strlen($temp);
            if ($len == 0) {
                return $value;
            }
        }
    }
99655
public function getBlockManager($idBlock)
    {
        $info = $this->getManagerInfoByBlockId($idBlock);

        return (null !== $info) ? $info['manager'] : null;
    }
1338831
public function getCacheTags(ReadBlockInterface $block)
    {
        $tags = array();

        $contents = $this->getContents($block->getAttribute('contentSearch'));;

        if ($contents) {

            foreach ($contents as $content) {
                $tags[] = $this->tagManager->formatContentIdTag($content->getContentId());

                $contentTypeTag = $this->tagManager->formatContentTypeTag($content->getContentType());
                if (!in_array($contentTypeTag, $tags)) {
                    $tags[] = $contentTypeTag;
                }
            }
        }

        return $tags;
    }
441441
public function displayBlock($name, $context, $blocks, $macros, $imports)
    {
        $blocks = $blocks + $this->blocks;
        $macros = $macros + $this->macros;
        $imports = $imports + $this->imports;

        if (isset($blocks[$name]) && is_callable($blocks[$name])) {
            return call_user_func(
                $blocks[$name], $context, $blocks, $macros, $imports
            );
        } else {
            return null;
        }
    }
135336
public function show($block)
    {
        /** @var DisplayBlockInterface $strategy */
        foreach ($this->strategies as $strategy) {
            if ($strategy->support($block)) {
                return $strategy->show($block);
            }
        }

        return $this->defaultStrategy->show($block);
    }
1009849
protected function block(OutputBlock $block)
    {
        if (empty($block->lines) && empty($block->children)) {
            return;
        }

        $this->currentBlock = $block;

        $pre = $this->indentStr();

        if (! empty($block->selectors)) {
            $this->blockSelectors($block);

            $this->indentLevel++;
        }

        if (! empty($block->lines)) {
            $this->blockLines($block);
        }

        if (! empty($block->children)) {
            $this->blockChildren($block);
        }

        if (! empty($block->selectors)) {
            $this->indentLevel--;

            if (empty($block->children)) {
                $this->write($this->break);
            }

            $this->write($pre . $this->close . $this->break);
        }
    }
849442
public function publish(BlockInterface $block)
    {
        if (!($block instanceof BlockOwnerInterface) && !$block->isShared()) {
            throw new \Exception ('Can only publish blocks of type BlockOwner or shared');
        }

        $this->killLoggableListener();
        $this->killSoftDeletableListener();

        $owned = $this->findByOwner($block);
        $version = $this->getNewVersion($block);

        foreach ($owned as $descendant) {
            $this->revertSingle($descendant, $version);
            $descendant->setPublish(true);
            $descendant->setVersion($version);
            $descendant->setRootVersion($version);
            $this->save($descendant);
        }

        $this->revertSingle($block, $version);
        $block->setPublish(true);
        $block->setVersion($version);
        $block->setRootVersion($version);
        $this->save($block);
    }
416070
public function getCacheTags(ReadBlockInterface $block)
    {
        $tags = array();

        $nodes = $this->getNodes($block);
        $siteId = $this->currentSiteManager->getSiteId();
        $tags[] = $this->tagManager->formatMenuTag($siteId);

        if ($nodes) {
            foreach ($nodes as $node) {
                $tags[] = $this->tagManager->formatNodeIdTag($node->getNodeId());
            }
        }

        return $tags;
    }
743313
public static function createBlockId(BlockInterface $block)
    {
        $id = '_'.$block->getName();

        if ($block->getParent() && $block->getOption('chained_block')) {
            $id = static::createBlockId($block->getParent()).$id;
        }

        return ltrim($id, '_0123456789');
    }