@param HasNodeInterface $page
@param string           $locale

@return HasNodeInterface
518699
public function getParentPage(HasNodeInterface $page, $locale)
    {
        /** @var Node $node */
        $node = $this->em->getRepository('KunstmaanNodeBundle:Node')->getNodeFor($page);
        $parentNode = $node->getParent();
        $nodeTranslation = $parentNode->getNodeTranslation($locale);
        $parentPage = $nodeTranslation->getRef($this->em);

        return $parentPage;
    }
1277078
public function getOrCreateProxyFromNode(NodeInterface $node, $locale = null)
    {
        $targetId = $node->getPath();
        $className = $this->documentClassMapper->getClassName($this->dm, $node);

        return $this->getOrCreateProxy($targetId, $className, $locale);
    }
363276
public function pendingReview($locale, $perPage = 0)
    {
        $underReview = $this->model->whereLocale($locale)->whereUnstable(1);
        return $perPage ? $underReview->paginate($perPage) : $underReview->get();
    }
1172119
public function hasTranslation($locale)
    {
        foreach ($this->translations as $translation) {
            if ($locale == $translation->locale) {
                return $translation;
            }
        }
        return false;
    }
501338
public function makeTranslationCopy(PageInterface $page, $locale)
    {
        $pageClass = $this->pageManager->getClassName();
        /** @var PageInterface $pageCopy */
        $pageCopy = new $pageClass();

        $pageCopy->setPageName($page->getPageName());
        $pageCopy->setMetaTitle($page->getMetaTitle());
        $pageCopy->setUrl($page->getUrl());
        $pageCopy->setMetaKeyword($page->getMetaKeyword());
        $pageCopy->setMetaDescription($page->getMetaDescription());
        $pageCopy->setActiveFrom($page->getActiveFrom());
        $pageCopy->setIsHome($page->getIsHome());
        $pageCopy->setLocale($locale);
        $pageCopy->setTemplateName($page->getTemplateName());
        $pageCopy->setOriginal($page);

        $layoutBlocks = $page->getLayoutBlock();
	    $om = $this->registry->getManager();

        foreach ($layoutBlocks as $layoutBlock) {

            /** @var $newLayoutBlock \Networking\InitCmsBundle\Model\LayoutBlockInterface */
            $newLayoutBlock = clone $layoutBlock;


            $content = $om->getRepository($newLayoutBlock->getClassType())->find(
                $newLayoutBlock->getObjectId()
            );
            $newContent = clone $content;

            $om->persist($newContent);
            $om->flush();

            $newLayoutBlock->setObjectId($newContent->getId());
            $newLayoutBlock->setPage($pageCopy);

            $om->persist($newLayoutBlock);
        }

	    $om->persist($pageCopy);

        $om->flush();

        return $pageCopy;
    }
1018296
public function hasTranslatedChildren($locale = null)
    {
        foreach ($this->getChildren() as $child)
        {
            if ($child->hasTranslation($locale))
            {
                return true;
            }
        }

        return false;
    }
550949
protected function filterLocale(Locale $locale)
    {
        $language = substr($locale->locale, 0, 2);

        $this->addLocale($locale->locale);
        $this->addLocale($language);
    }
69694
public function setLocale($locale)
    {
        $locale = substr($locale, 0, 2);
        if (in_array($locale, $this->locales)) {
            $this->locale = $locale;
            return true;
        }
        return false;
    }
591944
public function setLocale($locale)
    {
        if ($locale instanceof Locale) {
            $this->locale = $locale;
            return $this;
        }
        $this->locale = strtolower($locale);
        return $this;
    }
941948
public function hasNode(NodeInterface $node, $locale)
    {
        return array_key_exists($this->getNodeLocaleKey($node->getIdentifier(), $locale), $this->nodeDocumentMap);
    }
1353912
public function index($locale = null, $tab = null)
    {
        // If there are no locales, treat the first argument as the tab
        if (!($locales = Config::get('decoy.site.locales')) || empty($locales)) {
            $tab = $locale;
            $locale = null;

        // Otherwise, set a default locale if none was specified
        } elseif (!$locale) {
            $locale = Decoy::defaultLocale();
        }

        // Get all the elements for the current locale
        $elements = app('decoy.elements')->localize($locale)->hydrate(true);

        // If the user has customized permissions, filter the elements to only the
        // allowed pages of elements.
        if ($permissions = app('decoy.user')->getPermissionsAttribute()) {
            $elements->onlyPages($permissions->elements);
        }

        // If handling a deep link to a tab, verify that the passed tab
        // slug is a real key in the data.  Else 404.
        if ($tab && !in_array($tab, $elements->pluck('page_label')
            ->map(function ($title) {
                return Str::slug($title);
            })
            ->all())) {
            App::abort(404);
        }

        // Populate form
        Former::withRules($elements->rules());
        Former::populate($elements->populate());

        // Convert the collection to models for simpler manipulation
        $elements = $elements->asModels();

        // Set the breadcrumbs NOT include the locale/tab
        app('decoy.breadcrumbs')->set([
            route('decoy::elements') => $this->title,
        ]);

        // Render the view
        return $this->populateView('decoy::elements.index', [
            'elements' => $elements,
            'locale' => $locale,
            'tab' => $tab,
        ]);
    }
655036
public function htmlify(AbstractPage $page, $hasParent = false)
    {
        $html = '<li';
        if (! $hasParent) {
            $html .= ' class="active"';
        }
        $html .= '>';

        $label = $page->getLabel();
        if (null !== ($translator = $this->getTranslator())) {
            $label = $translator->translate($label, $this->getTranslatorTextDomain());
        }
        $escaper = $this->view->plugin('escapeHtml');
        $label = $escaper($label);

        if ($page->getHref() && ($hasParent || (! $hasParent && $this->getLinkLast())) &&
            (! ($page instanceof Uri) || $page->getUri() != '#')) {
            $anchorAttribs = $this->htmlAttribs(['href' => $page->getHref()]);
            $html .= '<a'.$anchorAttribs.'>'.$label.'</a>';
        } else {
            $html .= $label;
        }

        $html .= '</li>';

        return $html;
    }
222844
private function findRouteByPath($path, $locale)
    {
        $path = '/' . ltrim($path, '/');
        if (!array_key_exists($path, $this->routeCache)) {
            $this->routeCache[$path] = $this->routeRepository->findByPath($path, $locale);
        }

        return $this->routeCache[$path];
    }
791842
public function setLocale($locale = null)
    {
        if (is_null($locale)) {
            $locale = $this->getParent()->getLocale();
        }
        $this->locale = $locale;

        return $this;
    }
917020
private function updateChildrenPageTranslationPath(
        PageInterface $page,
        UnitOfWork $uow,
        ClassMetadata $metadata,
        $from,
        $to,
        $locale
    ) {
        // TODO use url generator or i18n routing prefix strategy
        $localePrefix = $locale != 'fr' ? '/' . $locale : '';
        foreach ($page->getChildren() as $child) {
            $translation = $child->translate($locale);
            $oldPath = $translation->getPath();
            if (0 === strpos($oldPath, $from)) {
                $newPath = str_replace($from, $to, $oldPath);
                $translation->setPath($newPath);
                $uow->recomputeSingleEntityChangeSet($metadata, $translation);

                if (0 < strlen($oldPath) && 0 < strlen($newPath) && $oldPath != $newPath) {
                    $this->redirections[] = array(
                        'from' => $localePrefix . $oldPath,
                        'to'   => $localePrefix . $newPath,
                    );
                }

                // Update the children pages translations paths.
                if ($child->hasChildren()) {
                    $this->updateChildrenPageTranslationPath($child, $uow, $metadata, $oldPath, $newPath, $locale);
                }
            }
        }
    }
729693
public function hasTranslation($locale = null)
    {
        $locale = $locale ?: \localizer\locale()->id();

        foreach ($this->cachedTranslations() as $translation) {
            if ((int) $translation->getAttribute($this->getLocaleKey()) === (int) $locale) {
                return true;
            }
        }

        return false;
    }
913254
public function linkAction(Request $request, $id, $locale)
    {
        /** @var PageInterface $page */
        $page = $this->admin->getObject($id);

        if (!$page) {
            throw new NotFoundHttpException(sprintf('unable to find the Page with id : %s', $id));
        }

        if ($request->getMethod() == 'POST') {
            $linkPageId = $request->get('page');
            if (!$linkPageId) {
                $this->get('session')->getFlashBag()->add('sonata_flash_error', 'flash_link_error');
            } else {
                /** @var PageInterface $linkPage */
                $linkPage = $this->admin->getObject($linkPageId);

                $page->addTranslation($linkPage);

                $this->admin->update($page);

                if ($this->isXmlHttpRequest()) {
                    $html = $this->renderView(
                        '@NetworkingInitCms/PageAdmin/page_translation_settings.html.twig',
                        ['object' => $page, 'admin' => $this->admin]
                    );

                    return $this->renderJson(
                        [
                            'result' => 'ok',
                            'html' => $html,
                        ]
                    );
                }

                $this->get('session')->getFlashBag()->add('sonata_flash_success', 'flash_link_success');

                return new RedirectResponse($this->admin->generateUrl('edit', ['id' => $page->getId()]));
            }
        }

        $pages = $this->admin->getModelManager()->findBy($this->admin->getClass(), ['locale' => $locale]);

        if (count($pages)) {
            $pages = new ArrayCollection($pages);
            $originalLocale = $page->getLocale();
            $pages = $pages->filter(
                function (PageInterface $linkPage) use ($originalLocale) {
                    return !in_array($originalLocale, $linkPage->getTranslatedLocales());
                }
            );
        }

        return $this->renderWithExtraParams(
            '@NetworkingInitCms/PageAdmin/page_translation_link_list.html.twig',
            [
                'page' => $page,
                'pages' => $pages,
                'locale' => $locale,
                'original_language' => \Locale::getDisplayLanguage($page->getLocale()),
                'language' => \Locale::getDisplayLanguage($locale),
                'admin' => $this->admin,
            ]
        );
    }