<commit_before><?php
/**
 * @author <NAME> <<EMAIL>>
 * @copyright Zicht Online <http://zicht.nl>
 */

namespace Zicht\Bundle\PageBundle\Controller;

use \Symfony\Component\HttpFoundation\Response;
use \Zicht\Bundle\PageBundle\Model\PageInterface;
use \Symfony\Component\HttpFoundation\RedirectResponse;

use \Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use \Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use \Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
use \Zicht\Bundle\PageBundle\Entity\ControllerPageInterface;
use \Symfony\Component\HttpFoundation\Request;

/**
 * Controller for public page actions
 */
class PageController extends AbstractController
{
    /**
     * Redirects to the page identified by the passed id.
     *
     * @param string $id
     * @return Response
     *
     * @Route("page/{id}/redirect", name="page_redirect")
     */
    public function redirectAction($id)
    {
        return new RedirectResponse($this->generateUrl('zicht_page_page_view', array('id' => $id)));
    }


    /**
     * Redirects to the specified page. This is useful for posting an autocomplete ID, which in turn redirects to
     * the specified page.
     *
     * @param Request $r
     * @return Response
     *
     * @Route("/goto")
     */
    public function gotoAction(Request $r)
    {
        return $this->redirect(
            $this->get('zicht_url.provider')->url($this->getPageManager()->findForView($r->get('id')))
        );
    }


    /**
     * View a page.
     *
     * @param string $id
     * @return Response
     *
     * @Route("page/{id}")
     */
    public function viewAction($id)
    {
        /** @var $pageManager \Zicht\Bundle\PageBundle\Manager\PageManager */
        $pageManager = $this->getPageManager();

        $page = $pageManager->findForView($id);

        if ($page instanceof ControllerPageInterface) {
            return $this->forward(
                $page->getController(),
                (array)$page->getControllerParameters(),
                $this->getRequest()->query->all()
                + array(
                    'parameters' => $this->getRequest()->query->all()
                )
                + array(
                    '_locale' => $this->getRequest()->attributes->get('_locale')
                )
            );
        }

        return $this->renderPage($page);
    }


    /**
     * Render a page with the specified additional template variables.
     *
     * @param \Zicht\Bundle\PageBundle\Model\PageInterface $page
     * @param array $vars
     * @return \Symfony\Component\HttpFoundation\Response
     */
    protected function renderPage(PageInterface $page, $vars = array())
    {
        return $this->render(
            $this->getPageManager()->getTemplate($page),
            $vars + array(
                'page' => $page,
                'id' => $page->getId(),
            )
        );
    }
}<commit_msg>use parameters as 'path' parameter.<commit_after><?php
/**
 * @author <NAME> <<EMAIL>>
 * @copyright Zicht Online <http://zicht.nl>
 */

namespace Zicht\Bundle\PageBundle\Controller;

use \Symfony\Component\HttpFoundation\Response;
use \Zicht\Bundle\PageBundle\Model\PageInterface;
use \Symfony\Component\HttpFoundation\RedirectResponse;

use \Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use \Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use \Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
use \Zicht\Bundle\PageBundle\Entity\ControllerPageInterface;
use \Symfony\Component\HttpFoundation\Request;

/**
 * Controller for public page actions
 */
class PageController extends AbstractController
{
    /**
     * Redirects to the page identified by the passed id.
     *
     * @param string $id
     * @return Response
     *
     * @Route("page/{id}/redirect", name="page_redirect")
     */
    public function redirectAction($id)
    {
        return new RedirectResponse($this->generateUrl('zicht_page_page_view', array('id' => $id)));
    }


    /**
     * Redirects to the specified page. This is useful for posting an autocomplete ID, which in turn redirects to
     * the specified page.
     *
     * @param Request $r
     * @return Response
     *
     * @Route("/goto")
     */
    public function gotoAction(Request $r)
    {
        return $this->redirect(
            $this->get('zicht_url.provider')->url($this->getPageManager()->findForView($r->get('id')))
        );
    }


    /**
     * View a page.
     *
     * @param string $id
     * @return Response
     *
     * @Route("page/{id}")
     */
    public function viewAction($id)
    {
        /** @var $pageManager \Zicht\Bundle\PageBundle\Manager\PageManager */
        $pageManager = $this->getPageManager();

        $page = $pageManager->findForView($id);

        if ($page instanceof ControllerPageInterface) {
            return $this->forward(
                $page->getController(),
                (array)$page->getControllerParameters()
                + array(
                    'parameters' => $this->getRequest()->query->all()
                ),
                $this->getRequest()->query->all()
                + array(
                    '_locale' => $this->getRequest()->attributes->get('_locale')
                )
            );
        }

        return $this->renderPage($page);
    }


    /**
     * Render a page with the specified additional template variables.
     *
     * @param \Zicht\Bundle\PageBundle\Model\PageInterface $page
     * @param array $vars
     * @return \Symfony\Component\HttpFoundation\Response
     */
    protected function renderPage(PageInterface $page, $vars = array())
    {
        return $this->render(
            $this->getPageManager()->getTemplate($page),
            $vars + array(
                'page' => $page,
                'id' => $page->getId(),
            )
        );
    }
}
{'fraction_non_alphanumeric': 0.13852153272295695, 'fraction_numerical': 0.0, 'mean_word_length': 2.2555187637969096, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 73, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '414057', 'n_tokens_mistral': 1655, 'n_tokens_neox': 1619, 'n_words': 326}