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,
            ]
        );
    }