<commit_before><?php

namespace Bs\CrudifyBundle\Controller;

use Bs\CrudifyBundle\Definition\DefinitionInterface;
use Bs\CrudifyBundle\Event\CrudifyEvents;
use Symfony\Component\HttpFoundation\Request;

class BaseController extends AbstractCrudController
{
    /**
     * {@inheritdoc}
     */
    public function indexAction(DefinitionInterface $definition, Request $request)
    {
        $query = $this->createSelectQuery($definition->getIndex());
        $grid = $this->getGrid($query, $definition, $request);

        return $this->render($definition->getIndexTemplate(), [
            'definition' => $definition,
            'objects' => $grid,
        ]);
    }

    /**
     * {@inheritdoc}
     */
    public function newAction(DefinitionInterface $definition, Request $request)
    {
        $form = $this->createCreateForm($definition);
        $object = $form->getData();

        return $this->render($definition->getNewTemplate(), [
            'definition' => $definition,
            'form' => $form->createView(),
            'object' => $object,
        ]);
    }

    /**
     * {@inheritdoc}
     */
    public function createAction(DefinitionInterface $definition, Request $request)
    {
        $form = $this->createCreateForm($definition);
        $form->handleRequest($request);
        $object = $form->getData();

        if ($form->isValid()) {
            $this->triggerEvent(CrudifyEvents::BEFORE_CREATE, $object, $definition);
            $manager = $definition->getEntityManager();
            $manager->persist($object);
            $manager->flush();
            $this->triggerEvent(CrudifyEvents::CREATE, $object, $definition);
            $this->addTranslatedFlash($definition, 'success', 'The object was created.');
            return $this->determineSuccessResponse($definition, $object, $request);
        }

        $this->addTranslatedFlash($definition, 'error', 'There were errors on the form.');
        return $this->render($definition->getNewTemplate(), [
            'definition' => $definition,
            'form' => $form->createView(),
            'object' => $object,
        ]);
    }

    /**
     * {@inheritdoc}
     */
    public function editAction(DefinitionInterface $definition, Request $request, $id)
    {
        $object = $this->retrieveObject($definition, $id);
        if (null === $object) {
            throw $this->createNotFoundException();
        }

        $form = $this->createUpdateForm($definition, $object);
        return $this->render($definition->getEditTemplate(), [
            'definition' => $definition,
            'form' => $form->createView(),
            'object' => $object,
        ]);
    }

    /**
     * {@inheritdoc}
     */
    public function updateAction(DefinitionInterface $definition, Request $request, $id)
    {
        $object = $this->retrieveObject($definition, $id);
        if (null === $object) {
            throw $this->createNotFoundException();
        }

        $form = $this->createUpdateForm($definition, $object);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $this->triggerEvent(CrudifyEvents::BEFORE_UPDATE, $object, $definition);
            $manager = $definition->getEntityManager();
            $manager->flush();
            $this->triggerEvent(CrudifyEvents::UPDATE, $object, $definition);
            $this->addTranslatedFlash($definition, 'success', 'The object was updated.');
            return $this->determineSuccessResponse($definition, $object, $request);
        }

        $this->addTranslatedFlash($definition, 'error', 'There were errors on the form.');
        return $this->render($definition->getEditTemplate(), [
            'definition' => $definition,
            'form' => $form->createView(),
            'object' => $object,
        ]);
    }

    /**
     * {@inheritdoc}
     */
    public function deleteAction(DefinitionInterface $definition, Request $request, $id)
    {
        $object = $this->retrieveObject($definition, $id);
        if (null === $object) {
            throw $this->createNotFoundException();
        }

        $form = $this->createDeleteForm($definition, $object);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $this->triggerEvent(CrudifyEvents::BEFORE_DELETE, $object, $definition);
            $manager = $definition->getEntityManager();
            $manager->remove($object);
            $manager->flush();
            $this->triggerEvent(CrudifyEvents::DELETE, $object, $definition);
            $this->addTranslatedFlash($definition, 'success', 'The object was removed.');
        } else {
            $this->addTranslatedFlash($definition, 'error', 'An error occured when trying to remove the object.');
        }

        return $this->redirect($this->generateUrl('bs_crudify.index', [
            'mapping' => $definition->getName(),
        ]));
    }
}
<commit_msg>Fixed template calls in basecontroller<commit_after><?php

namespace Bs\CrudifyBundle\Controller;

use Bs\CrudifyBundle\Definition\DefinitionInterface;
use Bs\CrudifyBundle\Event\CrudifyEvents;
use Symfony\Component\HttpFoundation\Request;

class BaseController extends AbstractCrudController
{
    /**
     * {@inheritdoc}
     */
    public function indexAction(DefinitionInterface $definition, Request $request)
    {
        $query = $this->createSelectQuery($definition->getIndex());
        $grid = $this->getGrid($query, $definition, $request);

        return $this->render($definition->getTemplates()->getIndex(), [
            'definition' => $definition,
            'objects' => $grid,
        ]);
    }

    /**
     * {@inheritdoc}
     */
    public function newAction(DefinitionInterface $definition, Request $request)
    {
        $form = $this->createCreateForm($definition);
        $object = $form->getData();

        return $this->render($definition->getTemplates()->getNew(), [
            'definition' => $definition,
            'form' => $form->createView(),
            'object' => $object,
        ]);
    }

    /**
     * {@inheritdoc}
     */
    public function createAction(DefinitionInterface $definition, Request $request)
    {
        $form = $this->createCreateForm($definition);
        $form->handleRequest($request);
        $object = $form->getData();

        if ($form->isValid()) {
            $this->triggerEvent(CrudifyEvents::BEFORE_CREATE, $object, $definition);
            $manager = $definition->getEntityManager();
            $manager->persist($object);
            $manager->flush();
            $this->triggerEvent(CrudifyEvents::CREATE, $object, $definition);
            $this->addTranslatedFlash($definition, 'success', 'The object was created.');
            return $this->determineSuccessResponse($definition, $object, $request);
        }

        $this->addTranslatedFlash($definition, 'error', 'There were errors on the form.');
        return $this->render($definition->getTemplates()->getNew(), [
            'definition' => $definition,
            'form' => $form->createView(),
            'object' => $object,
        ]);
    }

    /**
     * {@inheritdoc}
     */
    public function editAction(DefinitionInterface $definition, Request $request, $id)
    {
        $object = $this->retrieveObject($definition, $id);
        if (null === $object) {
            throw $this->createNotFoundException();
        }

        $form = $this->createUpdateForm($definition, $object);
        return $this->render($definition->getTemplates()->getEdit(), [
            'definition' => $definition,
            'form' => $form->createView(),
            'object' => $object,
        ]);
    }

    /**
     * {@inheritdoc}
     */
    public function updateAction(DefinitionInterface $definition, Request $request, $id)
    {
        $object = $this->retrieveObject($definition, $id);
        if (null === $object) {
            throw $this->createNotFoundException();
        }

        $form = $this->createUpdateForm($definition, $object);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $this->triggerEvent(CrudifyEvents::BEFORE_UPDATE, $object, $definition);
            $manager = $definition->getEntityManager();
            $manager->flush();
            $this->triggerEvent(CrudifyEvents::UPDATE, $object, $definition);
            $this->addTranslatedFlash($definition, 'success', 'The object was updated.');
            return $this->determineSuccessResponse($definition, $object, $request);
        }

        $this->addTranslatedFlash($definition, 'error', 'There were errors on the form.');
        return $this->render($definition->getTemplates()->getEdit(), [
            'definition' => $definition,
            'form' => $form->createView(),
            'object' => $object,
        ]);
    }

    /**
     * {@inheritdoc}
     */
    public function deleteAction(DefinitionInterface $definition, Request $request, $id)
    {
        $object = $this->retrieveObject($definition, $id);
        if (null === $object) {
            throw $this->createNotFoundException();
        }

        $form = $this->createDeleteForm($definition, $object);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $this->triggerEvent(CrudifyEvents::BEFORE_DELETE, $object, $definition);
            $manager = $definition->getEntityManager();
            $manager->remove($object);
            $manager->flush();
            $this->triggerEvent(CrudifyEvents::DELETE, $object, $definition);
            $this->addTranslatedFlash($definition, 'success', 'The object was removed.');
        } else {
            $this->addTranslatedFlash($definition, 'error', 'An error occured when trying to remove the object.');
        }

        return $this->redirect($this->generateUrl('bs_crudify.index', [
            'mapping' => $definition->getName(),
        ]));
    }
}

{'fraction_non_alphanumeric': 0.15778337531486147, 'fraction_numerical': 0.0, 'mean_word_length': 2.562814070351759, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 160, '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': '3865143', 'n_tokens_mistral': 2631, 'n_tokens_neox': 2606, 'n_words': 482}