Layout edition

@param Request $request
@param string $layoutId
@param string $lang

@throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
@return \Symfony\Component\HttpFoundation\Response
542960
public function editAction(Request $request, $layoutId, $lang = null)
    {
        $layout= $this->get('doctrine.orm.entity_manager')->find('LexikMailerBundle:Layout', $layoutId);

        if (!$layout) {
            throw $this->createNotFoundException(sprintf('No layout found for id "%d".', $layoutId));
        }

        $handler = $this->get('lexik_mailer.form.handler.layout');
        $form = $handler->createForm($layout, $lang);

        if ($handler->processForm($form, $request)) {
            return $this->redirect($this->generateUrl('lexik_mailer.layout_edit', array(
                'layoutId' => $layout->getId(),
                'lang'     => $lang,
            )));
        }

        return $this->render('LexikMailerBundle:Layout:edit.html.twig', array_merge(array(
            'form'          => $form->createView(),
            'base_layout'   => $this->container->getParameter('lexik_mailer.base_layout'),
            'layout'        => $layout,
            'lang'          => $lang,
            'displayLang'   => \Locale::getDisplayLanguage($lang),
            'routePattern'  => urldecode($this->generateUrl('lexik_mailer.layout_edit', array('layoutId' => $layout->getId(), 'lang' => '%lang%'), true)),
        ), $this->getAdditionalParameters()));
    }
698700
public function manipulate(\DOMDocument $document, LayoutInterface $layout): void
    {
        $host = '//' . $layout->getSource()->getHost();

        /** @var \DOMElement $anchor */
        foreach ($document->getElementsByTagName('a') as $anchor) {
            $this->replaceElementAttributeWithAbsoluteUri($anchor, 'href', $host);
        }

        /** @var \DOMElement $anchor */
        foreach ($document->getElementsByTagName('link') as $anchor) {
            $this->replaceElementAttributeWithAbsoluteUri($anchor, 'href', $host);
        }

        /** @var \DOMElement $anchor */
        foreach ($document->getElementsByTagName('img') as $anchor) {
            $this->replaceElementAttributeWithAbsoluteUri($anchor, 'src', $host);
        }

        /** @var \DOMElement $anchor */
        foreach ($document->getElementsByTagName('script') as $anchor) {
            $this->replaceElementAttributeWithAbsoluteUri($anchor, 'src', $host);
        }

        $xPath = new \DOMXPath($document);
        /** @var \DOMComment[] $comments */
        $comments = $xPath->query('//comment()');
        foreach ($comments as $comment) {
            $this->replaceCommentWithAbsoluteUri($comment, $host);
        }
    }
900268
static function LayoutTemplate(Layout $layout)
    {
        $folder = Path::Combine(PHINE_PATH, 'App/Phine/LayoutTemplates');
        $file = Path::Combine($folder, $layout->GetName());
        return Path::AddExtension($file, 'phtml');
    }
503968
public function editAction(Request $request, $emailId, $lang = null)
    {
        $class = $this->container->getParameter('lexik_mailer.email_entity.class');
        $email = $this->get('doctrine.orm.entity_manager')->find($class, $emailId);

        if (!$email) {
            throw $this->createNotFoundException(sprintf('No email found for id "%d"', $emailId));
        }

        $handler = $this->get('lexik_mailer.form.handler.email');
        $form = $handler->createForm($email, $lang);

        if ($handler->processForm($form, $request)) {
            return $this->redirect($this->generateUrl('lexik_mailer.email_edit', array(
                'emailId' => $email->getId(),
                'lang'    => $handler->getLocale(),
            )));
        }

        return $this->render('LexikMailerBundle:Email:edit.html.twig', array_merge(array(
            'form'          => $form->createView(),
            'layout'        => $this->container->getParameter('lexik_mailer.base_layout'),
            'email'         => $email,
            'lang'          => $handler->getLocale(),
            'displayLang'   => \Locale::getDisplayLanguage($handler->getLocale()),
            'routePattern'  => urldecode($this->generateUrl('lexik_mailer.email_edit', array('emailId' => $email->getId(), 'lang' => '%lang%'), true)),
        ), $this->getAdditionalParameters()));
    }
89221
public function setMiddleParagraphLayoutId( $layoutParagraphId = null )
    {
        $middleLayout = $this->middleLayoutModel
                             ->findMiddleParagraphLayoutById(
                                 $layoutParagraphId
                             );

        if ( ! empty( $middleLayout ) )
        {
            $controller = $this->getController();

            if ( ! method_exists( $controller, 'plugin' ) )
            {
                throw new Exception\LogicException(
                    'Controller used with paragraphLayout plugin must be pluggable'
                );
            }

            $controller->plugin( 'layout' )
                       ->setMiddleLayout( $middleLayout );
        }

        return $this;
    }
774469
public function getLayoutSetup($layoutId = '')
    {
        // Continue only if setup for given layout ID found.
        if (isset($this->layoutSetup[$layoutId])) {
            return $this->layoutSetup[$layoutId];
        }

        return $this->layoutSetup;
    }
732362
public function changeLayout(Request $request, $id)
    {
        $page = Page::findOrFail((int)$id);
        $page->layout = $request->layout;
        $page->save();

        return redirect()
            ->back()
            ->with([
                'message' => __('voyager::generic.successfully_updated') . " Page Layout",
                'alert-type' => 'success',
            ]);
    }
9218
public function renderPageByUrl($uri, $url, $locale, $layout = null)
    {
        $page = null;
        if ($viewReference = $this->viewReferenceRepository->getReferenceByUrl($url, $locale)) {
            $page = $this->findPageByReference($viewReference);
            $this->checkPageValidity($page, ['url' => $url, 'locale' => $locale]);
            $page->setReference($viewReference);

            if ($page instanceof BasePage
                && $page->getSeo()
                && $page->getSeo()->getRedirectTo()
                && $page->getSeo()->getRedirectTo()->getLinkType() != Link::TYPE_NONE
                && !$this->session->get('victoire.edit_mode', false)) {
                $link = $page->getSeo()->getRedirectTo();

                return new RedirectResponse($this->container->get('victoire_widget.twig.link_extension')->victoireLinkUrl($link->getParameters()));
            }

            return $this->renderPage($page, $layout);
        } else {
            try {
                /** @var Error404 $error404 */
                $error404 = $this->entityManager->getRepository('VictoireSeoBundle:Error404')->findOneBy(['url' => $uri]);
                /** @var Redirection $redirection */
                $redirection = $this->entityManager->getRepository('VictoireSeoBundle:Redirection')->findOneBy(['url' => $uri]);

                $result = $this->redirectionHandler->handleError($redirection, $error404);

                if ($result instanceof Redirection) {
                    return new RedirectResponse($this->container->get('victoire_widget.twig.link_extension')->victoireLinkUrl(
                        $result->getLink()->getParameters()
                    ), Response::HTTP_MOVED_PERMANENTLY);
                } elseif ($result->getRedirection()) {
                    return new RedirectResponse($this->container->get('victoire_widget.twig.link_extension')->victoireLinkUrl(
                        $result->getRedirection()->getLink()->getParameters()
                    ));
                }
            } catch (NoResultException $e) {
                $error = new Error404();

                $error->setUrl($uri);
                $error->setType($this->redirectionHandler->handleErrorExtension(pathinfo($uri, PATHINFO_EXTENSION)));

                $this->entityManager->persist($error);
                $this->entityManager->flush();
            }

            throw new NotFoundHttpException(sprintf('Page not found (url: "%s", locale: "%s")', $url, $locale));
        }
    }
1094146
protected function createLayoutTranslation(LayoutInterface $layout, array $config)
    {
        $translation = $this->newLayoutTranslationInstance($layout);
        $translation->setLocale(ConfigUtil::getValue($config, 'locale'));
        $translation->setLabel(ConfigUtil::getValue($config, 'label'));
        $translation->setDescription(ConfigUtil::getValue($config, 'description'));
        $translation->setBody(ConfigUtil::getValue($config, 'body'));

        return $translation;
    }
1181869
public function renderLayout($content, \Mmi\Http\Request $request)
    {
        return $this->isLayoutDisabled() ? $content : $this
                //ustawianie treści w placeholder 'content'
            ->setPlaceholder('content', $content)
                //renderowanie layoutu
            ->renderTemplate($this->_getLayout($request));
    }
950470
public function updateLayout(Layout $layout)
    {
        if (null === $layout->getSite()) {
            return false;
        }

        $layoutfile = $this->getLayoutFile($layout);
        File::resolveFilepath($layoutfile, null, array('include_path' => $this->_layoutdir));

        if (false === file_exists($layoutfile)) {
            File::resolveFilepath($layoutfile, null, array('base_dir' => $this->_layoutdir[1]));
        }

        if (false === file_exists($layoutfile) && false === touch($layoutfile)) {
            throw new RendererException(sprintf('Unable to create file %s.', $layoutfile), RendererException::LAYOUT_ERROR);
        }

        if (!is_writable($layoutfile)) {
            throw new RendererException(sprintf('Unable to open file %s in writing mode.', $layoutfile), RendererException::LAYOUT_ERROR);
        }

        return $layoutfile;
    }
772344
public function layoutAction(Request $request)
    {
        $container = $this->findContainerByRequest($request);

        $data = $request->request->get('data', []);

        try {
            $this->getEditor()->getLayoutAdapter()->updateContainerLayout($container, $data);
        } catch (EditorExceptionInterface $e) {
            return $this->handleException($e);
        }

        $this->validate($container);
        $this->persist($container);

        $data = [
            'containers' => [$this->getViewBuilder()->buildContainer($container)],
        ];

        return $this->buildResponse($data, self::SERIALIZE_LAYOUT);
    }
798763
public function removeTranslation(LayoutTranslation $translation)
    {
        $this->translations->removeElement($translation);
        $translation->setLayout(null);
    }
842378
public function renderSelf($layout = null, $title = null)
    {
        // Verify Existence of Layout Section + Layout:
        
        if (!$this->hasEnabledChild(LayoutSection::class)) {
            return $this->renderNotFound($layout, $title, LayoutSection::singleton()->i18n_singular_name());
        } elseif (!$this->getChild(LayoutSection::class)->hasPageLayout()) {
            return $this->renderNotFound($layout, $title, Layout::singleton()->i18n_singular_name());
        }
        
        // Verify Existence of Page Component:
        
        if (!$this->hasEnabledDescendant(PageComponent::class)) {
            return $this->renderNotFound($layout, $title, PageComponent::singleton()->i18n_singular_name());
        }
        
        // Render Template Sections:
        
        return $this->renderChildren($layout, $title);
    }
1142140
public function updateLayout(Layout $layout): void
    {
        $query = $this->connection->createQueryBuilder();
        $query
            ->update('ngbm_layout')
            ->set('type', ':type')
            ->set('name', ':name')
            ->set('description', ':description')
            ->set('created', ':created')
            ->set('modified', ':modified')
            ->set('shared', ':shared')
            ->set('main_locale', ':main_locale')
            ->where(
                $query->expr()->eq('id', ':id')
            )
            ->setParameter('id', $layout->id, Type::INTEGER)
            ->setParameter('type', $layout->type, Type::STRING)
            ->setParameter('name', $layout->name, Type::STRING)
            ->setParameter('description', $layout->description, Type::STRING)
            ->setParameter('created', $layout->created, Type::INTEGER)
            ->setParameter('modified', $layout->modified, Type::INTEGER)
            ->setParameter('shared', $layout->shared, Type::BOOLEAN)
            ->setParameter('main_locale', $layout->mainLocale, Type::STRING);

        $this->applyStatusCondition($query, $layout->status);

        $query->execute();
    }
1317108
public function createAction(Request $request)
    {
        $treeId = $request->get('tree_id');
        $eid = $request->get('eid');
        $layoutareaId = $request->get('layoutarea_id');
        $elementtypeId = $request->get('element_type_id');
        $prevId = $request->get('prev_id', 0);
        $inherit = $request->get('inherit') === 'on' ? true : false;
        $show = $request->get('shown_here') === 'on' ? true : false;
        $masterLanguage = $request->get('masterlanguage', null);

        if (!$masterLanguage) {
            $masterLanguage = $this->container->getParameter('phlexible_cms.languages.default');
        }

        $elementService = $this->get('phlexible_element.element_service');
        $teaserManager = $this->get('phlexible_teaser.teaser_manager');

        $elementSource = $elementService->findElementSource($elementtypeId);
        $userId = $this->getUser()->getId();

        $element = $elementService->createElement($elementSource, $masterLanguage, $userId);

        $stopIds = array();
        if (!$inherit) {
            $stopIds[] = $treeId;
        }

        $hideIds = array();
        if (!$show) {
            $hideIds[] = $treeId;
        }

        $teaser = $teaserManager->createTeaser(
            $treeId,
            $eid,
            $layoutareaId,
            'element',
            $element->getEid(),
            $prevId,
            $stopIds,
            $hideIds,
            $masterLanguage,
            $userId
        );

        return new ResultResponse(true, "Teaser with ID {$teaser->getId()} created.", ['language' => $masterLanguage]);
    }
922482
public function layoutAction(Request $request)
    {
        $block = $this->findBlockByRequest($request);

        $data = $request->request->get('data', []);

        try {
            $this->getEditor()->getLayoutAdapter()->updateBlockLayout($block, $data);
        } catch (EditorExceptionInterface $e) {
            return $this->handleException($e);
        }

        $this->validate($block);
        $this->persist($block);

        $data = [
            'blocks' => [$this->getViewBuilder()->buildBlock($block)],
        ];

        return $this->buildResponse($data, self::SERIALIZE_LAYOUT);
    }