<commit_before><?php

namespace FOS\RestBundle\View;

use Sensio\Bundle\FrameworkExtraBundle\View\AnnotationTemplateListener as BaseAnnotationTemplateListener;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
use Symfony\Component\HttpFoundation\Request;

/**
 * The AnnotationTemplateListener class handles the @extra:Template annotation.
 *
 * @author     <NAME> <<EMAIL>>
 */
class AnnotationTemplateListener extends BaseAnnotationTemplateListener
{
    /**
     * Renders the template and initializes a new response object with the 
     * rendered template content.
     *
     * @param GetResponseForControllerResultEvent $event A GetResponseForControllerResultEvent instance
     */
    public function onCoreView(GetResponseForControllerResultEvent $event)
    {
        $view = $event->getControllerResult();
        if (!($view instanceOf View)) {
            return parent::onCoreView($event);
        }

        $parameters = $view->getParameters();
        if (!$parameters) {
            $request = $event->getRequest();

            $vars = $request->attributes->get('_template_vars');
            if (!$vars) {
                $vars = $request->attributes->get('_template_default_vars');
            }

            $parameters = array();
            foreach ($vars as $var) {
                $parameters[$var] = $request->attributes->get($var);
            }

            $view->setParameters($parameters);
        }

        $template = $request->attributes->get('_template');
        if ($template) {
            unset($template['engine'], $template['format']);
            $view->setTemplate($template);
        }

        $event->setResponse($view->handle());
    }
}<commit_msg>reverted accidental commit that relies on https://github.com/sensio/FrameworkExtraBundle/pull/25 to be merged<commit_after><?php

namespace FOS\RestBundle\View;

use Sensio\Bundle\FrameworkExtraBundle\View\AnnotationTemplateListener as BaseAnnotationTemplateListener;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
use Symfony\Component\HttpFoundation\Request;

/**
 * The AnnotationTemplateListener class handles the @extra:Template annotation.
 *
 * @author     <NAME> Smith <<EMAIL>>
 */
class AnnotationTemplateListener extends BaseAnnotationTemplateListener
{
    /**
     * Renders the template and initializes a new response object with the 
     * rendered template content.
     *
     * @param GetResponseForControllerResultEvent $event A GetResponseForControllerResultEvent instance
     */
    public function onCoreView(GetResponseForControllerResultEvent $event)
    {
        $view = $event->getControllerResult();
        if (!($view instanceOf View)) {
            return parent::onCoreView($event);
        }

        $parameters = $view->getParameters();
        if (!$parameters) {
            $request = $event->getRequest();

            $vars = $request->attributes->get('_template_vars');
            if (!$vars) {
                $vars = $request->attributes->get('_template_default_vars');
            }

            $parameters = array();
            foreach ($vars as $var) {
                $parameters[$var] = $request->attributes->get($var);
            }

            $view->setParameters($parameters);
        }

        $template = $request->attributes->get('_template');
        if ($template) {
            $view->setTemplate($template);
        }

        $event->setResponse($view->handle());
    }

    /**
     * Guesses and returns the template name to render based on the controller
     * and action names.
     *
     * @param array $controller An array storing the controller object and action method
     * @param Request $request A Request instance
     * @throws \InvalidArgumentException
     */
    protected function guessTemplateName($controller, Request $request)
    {
        if (!preg_match('/Controller\\\(.*)Controller$/', get_class($controller[0]), $match)) {
            throw new \InvalidArgumentException(sprintf('The "%s" class does not look like a controller class (it does not end with Controller)', get_class($controller[0])));
        }

        $bundle = $this->getBundleForClass(get_class($controller[0]));
        $name = substr($controller[1], 0, -6);

        return array('bundle' => $bundle->getName(), 'controller' => $match[1], 'name' => $name);
    }
}
{'fraction_non_alphanumeric': 0.12267080745341614, 'fraction_numerical': 0.001996450754214729, 'mean_word_length': 2.9587357330992097, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 44, 'https://': 1, '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': '4421697', 'n_tokens_mistral': 1151, 'n_tokens_neox': 1123, 'n_words': 260}