@param string|array|PageInterface $page

@return PageInterface|null
9288
public function addPage($page)
    {
        if (is_array($page)) {
            $page = static::makePage($page);
        } elseif (is_string($page) or is_null($page)) {
            $title = $page;

            $page = app(PageInterface::class);
            $page->setTitle($title);
        }

        if (! ($page instanceof PageInterface)) {
            return;
        }

        $this->getPages()->push($page);

        return $page;
    }
198959
private function disablePageRelativeMenus(PageInterface $page)
    {
        $disabledMenus = false;
        if (!$page->isEnabled()) {

            // Disable menu children query
            $disableChildrenQuery = $this->em->createQuery(sprintf(
                'UPDATE %s m SET m.enabled = 0 WHERE m.root = :root AND m.left > :left AND m.right < :right',
                $this->menuClass
            ));

            // Disable pointing menus
            /** @var \Ekyna\Bundle\CmsBundle\Model\MenuInterface[] $menus */
            $menus = $this->em
                ->createQuery("SELECT m FROM {$this->menuClass} m WHERE m.route = :route")
                ->setParameter('route', $page->getRoute())
                ->getResult();
            if (!empty($menus)) {
                foreach ($menus as $menu) {
                    if ($menu->isEnabled()) {
                        $menu->setEnabled(false);
                        $this->em->persist($menu);
                        $disabledMenus = true;

                        $disableChildrenQuery->execute(array(
                            'root'  => $menu->getRoot(),
                            'left'  => $menu->getLeft(),
                            'right' => $menu->getRight(),
                        ));
                    }
                }
            }
        }
        return $disabledMenus;
    }
556596
public function page($page = null)
    {
        if (isset($page)) {
            $this->setPage($page);

            return $this;
        }

        return $this->getPage();
    }
1195197
public static function getTagsInSection(PageInterface $page = null, $group = null)
    {
        $page = $page ?: Router::getActivePage();

        $finder = new Tag\Finder\Finder();
        $finder->addFilter(new Tag\Finder\AppliedToPageDescendants($page));
        $finder->addFilter(new Tag\Finder\Group($group));

        return $finder->setOrderBy('name', 'asc')->findAll();
    }
634050
private function discardPageRedirections(PageInterface $page)
    {
        if ($page->isEnabled()) {
            /** @var \Ekyna\Bundle\CmsBundle\Model\PageTranslationInterface $translation */
            foreach ($page->getTranslations() as $locale => $translation) {
                // TODO use url generator or i18n routing prefix strategy
                $localePrefix = $locale != 'fr' ? '/' . $locale : '';
                $event = new DiscardRedirectionEvent($localePrefix . $translation->getPath());
                $this->dispatcher->dispatch(RedirectionEvents::DISCARD, $event);
            }
        }
    }
1245904
public function init(Page $page = null)
    {
        if (!$page) {
            return $this;
        }

        $this->page = $page;
        $this->online = $page->isOnline();
        $this->name = $page->getName();
        $this->meta = $page->getMeta();
        $this->openGraph = $page->getOpenGraph();
        $this->title = $page->getTitle();

        return $this;
    }
1226939
public function find(PageDocument $page)
    {
        $request = $this->requestStack->getCurrentRequest();

        $template = $page->getDefault(AbstractPhpcrDocument::DEFAULT_TEMPLATE_KEY);
        if ($template === null) {
            $defaults = [];

            /** @var RouteEnhancerInterface $enhancer */
            foreach ($this->dynamicRouter->getRouteEnhancers() as $enhancer) {
                $defaults = array_merge($defaults, $enhancer->enhance(['_content' => $page], $request));
            }

            if (array_key_exists(AbstractPhpcrDocument::DEFAULT_TEMPLATE_KEY, $defaults)) {
                $template = $defaults[AbstractPhpcrDocument::DEFAULT_TEMPLATE_KEY];
            }
        }

        return $template;
    }
163934
public function getDirectTranslationFor(PageInterface $page)
    {
        foreach ($this->getAllTranslations() as $translation) {
            if ($translation->isDirectTranslation($page)) {
                return $translation;
            }
        }
    }
1017894
public function save(PageInterface $page)
    {
        if (!$page->getId() && !$page->getContentRoute()->getTemplateName()) {
            $page->setContentRoute(new ContentRoute());
        }
        $this->_em->persist($page);
    }
1303734
public function setPage($page)
    {
        $this->page = null === $page ? null : (int)$page;
        $this->updateOffset();
        return $this;
    }
1157918
private function createResponseInstance(PageInterface $page)
    {
        $response = new Response();

        $response
            ->setLastModified($page->getUpdatedAt())
            ->setPublic();

        return $response;
    }
915254
public function getPage($intPage = 1)
    {
        $intPage--; // Convert page no. to index no.
        if ($intPage < 0) {
            $intPage = 0;
        }

        $this->__elements->seek($intPage);

        $objReturn = $this->__elements->current();
        if ($objReturn === false || get_class($objReturn) !== "ValidFormBuilder\\Page") {
            $objReturn = null;
        }

        return $objReturn;
    }
185180
public function fixUrl(PageInterface $page)
    {
        if ($page->isInternal()) {
            $page->setUrl(null); // internal routes do not have any url ...

            return;
        }

        // hybrid page cannot be altered
        if (!$page->isHybrid()) {
            // make sure Page has a valid url
            if ($page->getParent()) {
                if (!$page->getSlug()) {
                    $page->setSlug(Page::slugify($page->getName()));
                }

                if ('/' === $page->getParent()->getUrl()) {
                    $base = '/';
                } elseif ('/' !== mb_substr($page->getParent()->getUrl(), -1)) {
                    $base = $page->getParent()->getUrl() . '/';
                } else {
                    $base = $page->getParent()->getUrl();
                }

                if ('page_slug' === $page->getRouteName()) {
                    $page->setUrl($base . $page->getSlug() . '/');
                }
            } else {
                // a parent page does not have any slug - can have a custom url ...
                $page->setSlug(null);
                $page->setUrl('/' . $page->getSlug());
            }
        }

        foreach ($page->getChildren() as $child) {
            $this->fixUrl($child);
        }
    }
1233897
private function saveIfEmpty(Page $page)
    {
        $metadata = $this->container
                ->get('nestednode.metadata.resolver')
                ->resolve($page);

            $page->setMetaData($metadata);
            if ($this->container->get('em')->contains($page)) {
                $this->container->get('em')->flush($page);
            }

            return $page;
    }
810107
public function getDataForBreadcrumb(Page $page)
    {
        $parent = $page->getParent();
        if ($parent)
        {
            $data = array();
            if ($parent->getParent())
            {
                $data = array_merge($this->getDataForBreadcrumb($parent), $data);
            }
            $data[] = $parent;
            return $data;
        }
        return NULL;
    }
628926
public function index($page = null)
    {
        $url = sprintf('buckets/%d/questionnaires/%d/questions.json', $this->bucket, $this->parent);

        $questions = $this->client->get($url, [
            'query' => [
                'page' => $page,
            ],
        ]);

        return $this->indexResponse($questions, Question::class);
    }
286485
private function pageToArray(PageInterface $page, $locale)
    {
        $tabs = '';
        for ($l=0; $l<$page->getLevel();$l++) {
            $tabs .= ' • ';
        }

        return [
            'value' => $page->getId(),
            'title' => $tabs . $page->translate($locale)->getTitle(),
            'data'  => [
                'locked' => $page->isLocked(),
                'path'   => $this->generateUrl($page->getRoute(), ['_locale' => $locale]),
            ],
        ];
    }