<commit_before><?php

/*
 * This file is part of the EasyAdminBundle.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * Some parts of this file are copied and/or inspired by the
 * DoctrineCRUDGenerator included in the SensioGeneratorBundle.
 *   License: MIT License
 *   Copyright: (c) <NAME> <<EMAIL>>
 *   Source: https://github.com/sensiolabs/SensioGeneratorBundle
 */

namespace JavierEguiluz\Bundle\EasyAdminBundle\Controller;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Doctrine\Bundle\DoctrineBundle\Mapping\DisconnectedMetadataFactory;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
use Pagerfanta\Pagerfanta;
use Pagerfanta\Adapter\DoctrineORMAdapter;

class AdminController extends Controller
{
    protected $allowedActions = array('list', 'edit', 'new', 'show', 'search', 'delete');
    protected $config;
    protected $entity;
    protected $request;

    protected function initialize(Request $request)
    {
        $this->config = $this->container->getParameter('easy_admin.config');

        if (0 === count($this->config['entities'])) {
            return $this->render('@EasyAdmin/error/no_entities.html.twig');
        }

        if (!in_array($action = $request->get('action', 'list'), $this->allowedActions)) {
            return $this->render('@EasyAdmin/error/forbidden_action.html.twig', array(
                'action' => $action,
                'allowed_actions' => $this->allowedActions,
            ));
        }

        if (null !== $entityName = $request->get('entity')) {
            $this->entity['name'] = $entityName;
            $this->entity['class'] = $this->config['entities'][$entityName]['class'];
            $this->entity['metadata'] = $this->getEntityMetadata($this->entity['class']);
        }

        if (!$request->query->has('sortField')) {
            $request->query->set('sortField', 'id');
        }
        if (!$request->query->has('sortDirection')) {
            $request->query->set('sortDirection', 'DESC');
        }

        $this->em = $this->getDoctrine()->getManager();
    }

    /**
     * @Route("/", name="admin")
     */
    public function indexAction(Request $request)<commit_msg>Use 404 HTTP status code instead of 200 for custom error pages<commit_after><?php

/*
 * This file is part of the EasyAdminBundle.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * Some parts of this file are copied and/or inspired by the
 * DoctrineCRUDGenerator included in the SensioGeneratorBundle.
 *   License: MIT License
 *   Copyright: (c) <NAME> <<EMAIL>>
 *   Source: https://github.com/sensiolabs/SensioGeneratorBundle
 */

namespace JavierEguiluz\Bundle\EasyAdminBundle\Controller;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Doctrine\Bundle\DoctrineBundle\Mapping\DisconnectedMetadataFactory;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
use Pagerfanta\Pagerfanta;
use Pagerfanta\Adapter\DoctrineORMAdapter;

class AdminController extends Controller
{
    protected $allowedActions = array('list', 'edit', 'new', 'show', 'search', 'delete');
    protected $config;
    protected $entity;
    protected $request;

    protected function initialize(Request $request)
    {
        $this->config = $this->container->getParameter('easy_admin.config');

        if (0 === count($this->config['entities'])) {
            return $this->render('@EasyAdmin/error/no_entities.html.twig', array(), new Response('', 404));
        }

        if (!in_array($action = $request->get('action', 'list'), $this->allowedActions)) {
            return $this->render('@EasyAdmin/error/forbidden_action.html.twig', array(
                'action' => $action,
                'allowed_actions' => $this->allowedActions,
            ), new Response('', 404));
        }

        if (null !== $entityName = $request->get('entity')) {
            $this->entity['name'] = $entityName;
            $this->entity['class'] = $this->config['entities'][$entityName]['class'];
            $this->entity['metadata'] = $this->getEntityMetadata($this->entity['class']);
        }

        if (!$request->query->has('sortField')) {
            $request->query->set('sortField', 'id');
        }
        if (!$request->query->has('sortDirection')) {
            $request->query->set('sortDirection', 'DESC');
        }

        $this->em = $this->getDoctrine()->getManager();
    }

    /**
     * @Route("/", name="admin")
     */
    public function indexAction(Request $request)
{'fraction_non_alphanumeric': 0.1536761751707513, 'fraction_numerical': 0.002812374447569305, 'mean_word_length': 3.3790677220756375, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 73, 'https://': 2, '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': '2860510', 'n_tokens_mistral': 1422, 'n_tokens_neox': 1390, 'n_words': 297}