<commit_before><?php

namespace Ojs\JournalBundle\Controller;

use APY\DataGridBundle\Grid\Column\ActionsColumn;
use APY\DataGridBundle\Grid\Source\Entity;
use Doctrine\Common\Util\Debug;
use Doctrine\ORM\QueryBuilder;
use Ojs\Common\Helper\ActionHelper;
use Ojs\JournalBundle\Entity\Journal;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

use Ojs\JournalBundle\Entity\JournalsIndex;
use Ojs\JournalBundle\Form\JournalsIndexType;
use Symfony\Component\HttpFoundation\Response;

/**
 * JournalsIndex controller.
 *
 */
class JournalsIndexController extends Controller
{

    /**
     * Lists all JournalsIndex entities.
     *
     */
    public function indexAction($journal = null)
    {
        if (!$journal) {
            $journal = $this->get("ojs.journal_service")->getSelectedJournal()->getId();
        }
        $source = new Entity('OjsJournalBundle:JournalsIndex');
        if ($journal) {
            $ta = $source->getTableAlias();
            $source->manipulateQuery(function (QueryBuilder $qb) use ($journal, $ta) {
                $qb->andWhere(
                    $qb->expr()->eq("$ta.journal_id", ':journal')
                )
                    ->setParameter('journal', $journal);
            });
        }
        $grid = $this->get('grid')->setSource($source);

        $actionColumn = new ActionsColumn("actions", 'actions');
        $rowAction[] = ActionHelper::showAction('manager_journals_indexes_show', 'id');
        $rowAction[] = ActionHelper::editAction('manager_journals_indexes_edit', 'id');
        $rowAction[] = ActionHelper::deleteAction('manager_journals_indexes_delete', 'id');

        $actionColumn->setRowActions($rowAction);
        $grid->addColumn($actionColumn);
        $data = [];
        $data['grid'] = $grid;
        $data['journal_id'] = $journal;
        return $grid->getGridResponse('OjsJournalBundle:JournalsIndex:index.html.twig', $data);
    }

    /**
     * Creates a new JournalsIndex entity.
     *
     */
    public function createAction(Request $request, $journal = null)
    {
        $em = $this->getDoctrine()->getManager();
        $entity = new JournalsIndex();
        if ($journal) {
            $journalObj = $em->find('OjsJournalBundle:Journal', $journal);
            $entity->setJournalId($journal);
            $entity->setJournal($journalObj);
        }
        $form = $this->createCreateForm($entity);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $entity->setJournalIndexId($entity->getJournalIndex()->getId());
            $em->persist($entity);
            $em->flush();

            return $this->redirect($this->generateUrl('manager_journals_indexes_show', array('id' => $entity->getId())));
        }

        return $this->render('OjsJournalBundle:JournalsIndex:new.html.twig', array(
            'entity' => $entity,
            'form' => $form->createView(),
        ));
    }

    /**
     * Creates a form to create a JournalsIndex entity.
     *
     * @param JournalsIndex $entity The entity
     *
     * @return \Symfony\Component\Form\Form The form
     */
    private function createCreateForm(JournalsIndex $entity)
    {
        $form = $this->createForm(new JournalsIndexType(), $entity, array(
            'action' => $this->generateUrl('manager_journals_indexes_create', ['journal' => $entity->getJournalId()]),
            'method' => 'POST',
            'user' => $this->getUser()
        ));

        $form->add('submit', 'submit', array('label' => 'Create'));

        return $form;
    }

    /**
     * Displays a form to create a new JournalsIndex entity.
     * @param $journal integer
     * @return Response
     */
    public function newAction($journal = null)
    {
        $entity = new JournalsIndex();

        if ($journal) {
            $entity->setJournalId($journal);
        }
        $form = $this->createCreateForm($entity);

        return $this->render('OjsJournalBundle:JournalsIndex:new.html.twig', array(
            'entity' => $entity,
            'form' => $form->createView(),
        ));
    }

    /**
     * Finds and displays a JournalsIndex entity.
     *
     */
    public function showAction($id)
    {
        $em = $this->getDoctrine()->getManager();

        $entity = $em->getRepository('OjsJournalBundle:JournalsIndex')->find($id);

        if (!$entity) {
            throw $this->createNotFoundException('Unable to find JournalsIndex entity.');
        }

        $deleteForm = $this->createDeleteForm($id);

        return $this->render('OjsJournalBundle:JournalsIndex:show.html.twig', array(
            'entity' => $entity,<commit_msg>JournalsIndexs only viewable by journal managers.<commit_after><?php

namespace Ojs\JournalBundle\Controller;

use APY\DataGridBundle\Grid\Column\ActionsColumn;
use APY\DataGridBundle\Grid\Source\Entity;
use Doctrine\Common\Util\Debug;
use Doctrine\ORM\QueryBuilder;
use Ojs\Common\Helper\ActionHelper;
use Ojs\JournalBundle\Entity\Journal;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

use Ojs\JournalBundle\Entity\JournalsIndex;
use Ojs\JournalBundle\Form\JournalsIndexType;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

/**
 * JournalsIndex controller.
 *
 */
class JournalsIndexController extends Controller
{

    /**
     * Lists all JournalsIndex entities.
     *
     */
    public function indexAction($journal = null)
    {
        $journal = $this->get("ojs.journal_service")->getSelectedJournal()->getId();
        $source = new Entity('OjsJournalBundle:JournalsIndex');
        if ($journal) {
            $ta = $source->getTableAlias();
            $source->manipulateQuery(function (QueryBuilder $qb) use ($journal, $ta) {
                $qb->andWhere(
                    $qb->expr()->eq("$ta.journal_id", ':journal')
                )
                    ->setParameter('journal', $journal);
            });
        }
        if (!$journal)
            throw new NotFoundHttpException("Journal not found!");
        $grid = $this->get('grid')->setSource($source);

        $actionColumn = new ActionsColumn("actions", 'actions');
        $rowAction[] = ActionHelper::showAction('manager_journals_indexes_show', 'id');
        $rowAction[] = ActionHelper::editAction('manager_journals_indexes_edit', 'id');
        $rowAction[] = ActionHelper::deleteAction('manager_journals_indexes_delete', 'id');

        $actionColumn->setRowActions($rowAction);
        $grid->addColumn($actionColumn);
        $data = [];
        $data['grid'] = $grid;
        $data['journal_id'] = $journal;
        return $grid->getGridResponse('OjsJournalBundle:JournalsIndex:index.html.twig', $data);
    }

    /**
     * Creates a new JournalsIndex entity.
     *
     */
    public function createAction(Request $request, $journal = null)
    {
        $journal = $this->get("ojs.journal_service")->getSelectedJournal()->getId();
        $em = $this->getDoctrine()->getManager();
        $entity = new JournalsIndex();
        if ($journal) {
            $journalObj = $em->find('OjsJournalBundle:Journal', $journal);
            $entity->setJournalId($journal);
            $entity->setJournal($journalObj);
        }
        if (!$journal)
            throw new NotFoundHttpException("Journal not found!");
        $form = $this->createCreateForm($entity);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $entity->setJournalIndexId($entity->getJournalIndex()->getId());
            $em->persist($entity);
            $em->flush();

            return $this->redirect($this->generateUrl('manager_journals_indexes_show', array('id' => $entity->getId())));
        }

        return $this->render('OjsJournalBundle:JournalsIndex:new.html.twig', array(
            'entity' => $entity,
            'form' => $form->createView(),
        ));
    }

    /**
     * Creates a form to create a JournalsIndex entity.
     *
     * @param JournalsIndex $entity The entity
     *
     * @return \Symfony\Component\Form\Form The form
     */
    private function createCreateForm(JournalsIndex $entity)
    {
        $form = $this->createForm(new JournalsIndexType(), $entity, array(
            'action' => $this->generateUrl('manager_journals_indexes_create', ['journal' => $entity->getJournalId()]),
            'method' => 'POST',
            'user' => $this->getUser()
        ));

        $form->add('submit', 'submit', array('label' => 'Create'));

        return $form;
    }

    /**
     * Displays a form to create a new JournalsIndex entity.
     * @param $journal integer
     * @return Response
     */
    public function newAction($journal = null)
    {
        $entity = new JournalsIndex();
        $journal = $this->get("ojs.journal_service")->getSelectedJournal()->getId();
        if ($journal) {
            $entity->setJournalId($journal);
        }
        if(!$journal)
            throw new NotFoundHttpException('Journal not found!');
        $form = $this->createCreateForm($entity);

        return $this->render('OjsJournalBundle:JournalsIndex:new.html.twig', array(
            'entity' => $entity,
            'form' => $form->createView(),
        ));
    }

    /**
     * Finds and displays a JournalsIndex entity.
     *
     */
    public function showAction($id)
    {
        $em = $this->getDoctrine()->getManager();

        $entity = $em->getRepository('OjsJournalBundle:JournalsIndex')->find($id);

        if (!$entity) {
            throw $this->createNotFoundException('Unable to find JournalsIndex entity.');
        }

        $deleteForm = $this->createDeleteForm($id);

        return $this->render('OjsJournalBundle:JournalsIndex:show.html.twig', array(
            'entity' => $entity,
{'fraction_non_alphanumeric': 0.1521012658227848, 'fraction_numerical': 0.0, 'mean_word_length': 2.676842889054356, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 127, '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': '4821962', 'n_tokens_mistral': 2827, 'n_tokens_neox': 2786, 'n_words': 486}