<commit_before><?php

namespace Alpixel\Bundle\CMSBundle\Controller;

use Alpixel\Bundle\CMSBundle\Entity\Node;
use Alpixel\Bundle\SEOBundle\Annotation\MetaTag;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class FrontNodeController extends Controller
{
    /**
     * @MetaTag("node", providerClass="Alpixel\Bundle\CMSBundle\Entity\Node", title="Page de contenu")
     * @ParamConverter("node", options={"mapping" : {"slug": "slug"}})
     * @Method("GET")
     */
    public function dispatchAction(Request $request, Node $node)
    {
        $object = $this->get('cms.helper')->getNodeElementEntityFromNode($node);

        if ($object !== null && $object->getNode()->getPublished()) {
            if (stripos($request->getLocale(), $object->getNode()->getLocale()) !== false) {
                $contentType = $this->get('cms.helper')->getContentTypeFromNodeElementClass($object);
                $controller = explode('::', $contentType['controller']);
                if (count($controller) !== 2) {
                    throw new \LogicException('The parameter controller must be a valid callable controller, like "My\Namespace\Controller\Class::method"');
                } elseif (!class_exists($controller[0]) || !method_exists($controller[0], $controller[1])) {
                    throw new \LogicException(sprintf(
                        'Unable to find the "%s" controller or the method "%s" doesn\'t exist.',
                        $controller[0],
                        $controller[1]
                    ));
                }

                return $this->forward($contentType['controller'], [
                    '_route'        => $request->attributes->get('_route'),
                    '_route_params' => $request->attributes->get('_route_params'),
                    'object'        => $object,
                ]);
            }
        }

        throw $this->createNotFoundException();
    }

    public function displayNodeAdminBarAction(Node $node)
    {
        $canEdit = $this->get('request')->cookies->get('can_edit');

        if ($canEdit !== null && $canEdit === hash('sha256', 'can_edit'.$this->container->getParameter('secret'))) {
            return $this->render('CMSBundle:admin:blocks/admin_bar_page.html.twig', [
                'link' => $this->generateUrl('admin_alpixel_cms_node_editContent', ['id' => $node->getId()]),
            ]);
        }

        return new Response();
    }

    public function displayCustomAdminBarAction($link)
    {
        $canEdit = $this->get('request')->cookies->get('can_edit');

        if ($canEdit !== null && $canEdit === hash('sha256', 'can_edit'.$this->container->getParameter('secret'))) {
            return $this->render('CMSBundle:admin:blocks/admin_bar_page.html.twig', [
                'link' => $link,
            ]);
        }

        return new Response();
    }
}
<commit_msg>Update FrontNodeController.php<commit_after><?php

namespace Alpixel\Bundle\CMSBundle\Controller;

use Alpixel\Bundle\CMSBundle\Entity\Node;
use Alpixel\Bundle\SEOBundle\Annotation\MetaTag;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class FrontNodeController extends Controller
{
    /**
     * @MetaTag("node", providerClass="Alpixel\Bundle\CMSBundle\Entity\Node", title="Page de contenu")
     * @ParamConverter("node", options={"mapping" : {"slug": "slug"}})
     * @Method("GET")
     */
    public function dispatchAction(Request $request, Node $node)
    {
        $object = $this->get('cms.helper')->getNodeElementEntityFromNode($node);

        if ($object !== null && $object->getNode()->getPublished()) {
            if (stripos($request->getLocale(), $object->getNode()->getLocale()) !== false) {
                $contentType = $this->get('cms.helper')->getContentTypeFromNodeElementClass($object);
                $controller = explode('::', $contentType['controller']);
                if (count($controller) !== 2) {
                    throw new \LogicException('The parameter controller must be a valid callable controller, like "My\Namespace\Controller\Class::method"');
                } elseif (!class_exists($controller[0]) || !method_exists($controller[0], $controller[1])) {
                    throw new \LogicException(sprintf(
                        'Unable to find the "%s" controller or the method "%s" doesn\'t exist.',
                        $controller[0],
                        $controller[1]
                    ));
                }

                return $this->forward($contentType['controller'], [
                    '_route'        => $request->attributes->get('_route'),
                    '_route_params' => $request->attributes->get('_route_params'),
                    'object'        => $object,
                ]);
            }
        }

        throw $this->createNotFoundException();
    }

    public function displayNodeAdminBarAction(Node $node)
    {
        $canEdit = $this->get('request')->cookies->get('can_edit');

        if ($canEdit !== null && $canEdit === hash('sha256', 'can_edit'.$this->container->getParameter('secret'))) {
            return $this->render('CMSBundle:admin:blocks/admin_bar_page.html.twig', [
                'link' => $this->generateUrl('cms_node_editContent', ['id' => $node->getId()]),
            ]);
        }

        return new Response();
    }

    public function displayCustomAdminBarAction($link)
    {
        $canEdit = $this->get('request')->cookies->get('can_edit');

        if ($canEdit !== null && $canEdit === hash('sha256', 'can_edit'.$this->container->getParameter('secret'))) {
            return $this->render('CMSBundle:admin:blocks/admin_bar_page.html.twig', [
                'link' => $link,
            ]);
        }

        return new Response();
    }
}

{'fraction_non_alphanumeric': 0.15791164658634538, 'fraction_numerical': 0.0038554216867469878, 'mean_word_length': 2.5967648757943387, 'pattern_counts': {'":': 2, '<': 5, '<?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': '953045', 'n_tokens_mistral': 1693, 'n_tokens_neox': 1634, 'n_words': 277}