<commit_before><?php
/**
 * @author adelbertsilla
 */

namespace HealthCareAbroad\AdminBundle\Controller;

use Doctrine\Common\Util\Inflector;

use HealthCareAbroad\HelperBundle\Services\LocationService;

use Symfony\Component\Form\FormError;

use Symfony\Component\HttpFoundation\Request;

use HealthCareAbroad\AdminBundle\Event\AdminBundleEvents;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use HealthCareAbroad\HelperBundle\Entity\State;
use HealthCareAbroad\HelperBundle\Form\StateFormType;
use JMS\SecurityExtraBundle\Annotation\PreAuthorize;

class StateController extends Controller
{
    /**
     * @PreAuthorize("hasAnyRole('SUPER_ADMIN', 'CAN_VIEW_STATES')")
     *
     */
    public function indexAction()
    {
        return $this->render('AdminBundle:State:index.html.twig', array(
            'statusNew' => State::STATUS_NEW,
            'statuses' => array(State::STATUS_NEW => 'New', State::STATUS_ACTIVE => 'Active', State::STATUS_INACTIVE => 'Inactive'),
            'states' => $this->filteredResult,
            'pager' => $this->pager
        ));
    }

    /**
     * @PreAuthorize("hasAnyRole('SUPER_ADMIN', 'CAN_MANAGE_STATE')")
     */
    public function addAction()
    {
        $form = $this->createForm(New StateFormType());

        return $this->render('AdminBundle:State:form.html.twig', array(
            'id' => null,
            'form' => $form->createView(),
            'formAction' => $this->generateUrl('admin_state_create')
        ));
    }

    /**
     * @PreAuthorize("hasAnyRole('SUPER_ADMIN', 'CAN_MANAGE_STATE')")
     */
    public function editAction($id)
    {
        $state = $this->get('services.location')->findGlobalStateById($id); 
        if(isset($state['geoCountry'])) {
            $state['geoCountry'] = $state['geoCountry']['id'];
        }

        $form = $this->createForm(New StateFormType(), $state);

        return $this->render('AdminBundle:State:form.html.twig', array(
            'id' => $id,
            'form' => $form->createView(),<commit_msg>Fixed admin edit state bug.<commit_after><?php
/**
 * @author adelbertsilla
 */

namespace HealthCareAbroad\AdminBundle\Controller;

use Doctrine\Common\Util\Inflector;

use HealthCareAbroad\HelperBundle\Services\LocationService;

use Symfony\Component\Form\FormError;

use Symfony\Component\HttpFoundation\Request;

use HealthCareAbroad\AdminBundle\Event\AdminBundleEvents;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use HealthCareAbroad\HelperBundle\Entity\State;
use HealthCareAbroad\HelperBundle\Form\StateFormType;
use JMS\SecurityExtraBundle\Annotation\PreAuthorize;

class StateController extends Controller
{
    /**
     * @PreAuthorize("hasAnyRole('SUPER_ADMIN', 'CAN_VIEW_STATES')")
     *
     */
    public function indexAction()
    {
        return $this->render('AdminBundle:State:index.html.twig', array(
            'statusNew' => State::STATUS_NEW,
            'statuses' => array(State::STATUS_NEW => 'New', State::STATUS_ACTIVE => 'Active', State::STATUS_INACTIVE => 'Inactive'),
            'states' => $this->filteredResult,
            'pager' => $this->pager
        ));
    }

    /**
     * @PreAuthorize("hasAnyRole('SUPER_ADMIN', 'CAN_MANAGE_STATE')")
     */
    public function addAction()
    {
        $form = $this->createForm(New StateFormType());

        return $this->render('AdminBundle:State:form.html.twig', array(
            'id' => null,
            'form' => $form->createView(),
            'formAction' => $this->generateUrl('admin_state_create')
        ));
    }

    /**
     * @PreAuthorize("hasAnyRole('SUPER_ADMIN', 'CAN_MANAGE_STATE')")
     */
    public function editAction($id)
    {
        $state = $this->get('services.location')->getGlobalStateById($id); 
        if(isset($state['geoCountry'])) {
            $state['geoCountry'] = $state['geoCountry']['id'];
        }

        $form = $this->createForm(New StateFormType(), $state);

        return $this->render('AdminBundle:State:form.html.twig', array(
            'id' => $id,
            'form' => $form->createView(),
{'fraction_non_alphanumeric': 0.15412186379928317, 'fraction_numerical': 0.0, 'mean_word_length': 3.3333333333333335, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 51, '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': '1791554', 'n_tokens_mistral': 1273, 'n_tokens_neox': 1266, 'n_words': 179}