<commit_before><?php
/**
 * Created by PhpStorm.
 * User: Nikoms
 * Date: 15/02/14
 * Time: 16:42
 */

namespace Acme\DemoBundle\Rest\Controller;


use FOS\RestBundle\Controller\Annotations\View;
use FOS\RestBundle\Controller\FOSRestController;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use FOS\RestBundle\Controller\Annotations as Rest;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;


use FOS\RestBundle\Controller\Annotations\RouteResource;
use FOS\RestBundle\Controller\Annotations\Prefix;
use FOS\RestBundle\Controller\Annotations\NamePrefix;

/**
 * NamePrefix("api_")
 * Prefix("/api")
 * Pour ne pas écrire "getPostAction"
 * @RouteResource("Post")
 */
class PostController extends FOSRestController
{

    /**
     * Pour ne pas faire de $this->view et return $this->handleView
     * @View()
     */
    public function cgetAction()
    {
        $em = $this->getDoctrine()->getManager();
        $posts = $em->getRepository('AcmeDemoBundle:Post')->findAll();

        return $posts;
    }

    /**
     * Pour ne pas faire de $this->view et return $this->handleView
     * @View()
     */
    public function getAction($id)
    {
        $em = $this->getDoctrine()->getManager();
        $post = $em->getRepository('AcmeDemoBundle:Post')->findOneById($id);

        //Pas nécessaire, si pas mis, on revient à la page précédente
        if (!is_object($post)) {
            throw $this->createNotFoundException();
        }

        return $post;
    }

    /**
     * @View()
     */
    public function deleteAction($id)
    {
        echo 'ici';
        exit();
    }

}<commit_msg>Nouvelle structure pour REST<commit_after><?php
/**
 * Created by PhpStorm.
 * User: Nikoms
 * Date: 15/02/14
 * Time: 16:42
 */

namespace Acme\DemoBundle\Rest\Controller;


use FOS\RestBundle\Controller\Annotations\View;
use FOS\RestBundle\Controller\FOSRestController;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use FOS\RestBundle\Controller\Annotations as Rest;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;


use FOS\RestBundle\Controller\Annotations\RouteResource;
use FOS\RestBundle\Controller\Annotations\Prefix;
use FOS\RestBundle\Controller\Annotations\NamePrefix;

/**
 * NamePrefix("api_")
 * Prefix("/api")
 * Pour ne pas écrire "getPostAction"
 * @RouteResource("Post")
 */
class PostController extends FOSRestController
{

    /**
     * Pour ne pas faire de $this->view et return $this->handleView
     * @View()
     */
    public function cgetAction()
    {
        $em = $this->getDoctrine()->getManager();
        $posts = $em->getRepository('AcmeDemoBundle:Post')->findAll();

        return array(
            'entities' => $posts
        );
    }

    /**
     * Pour ne pas faire de $this->view et return $this->handleView
     * @View()
     */
    public function getAction($id)
    {
        $em = $this->getDoctrine()->getManager();
        $post = $em->getRepository('AcmeDemoBundle:Post')->findOneById($id);

        //Pas nécessaire, si pas mis, on revient à la page précédente
        if (!is_object($post)) {
            throw $this->createNotFoundException();
        }

        return array('entity' => $post);
    }

    /**
     * @View()
     */
    public function deleteAction($id)
    {
        echo 'ici';
        exit();
    }

}
{'fraction_non_alphanumeric': 0.13473457289140395, 'fraction_numerical': 0.0053893829156561575, 'mean_word_length': 3.1707865168539326, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, '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': '1559324', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1118, 'n_words': 222}