<commit_before><?php

namespace Faithlead\RestBundle\Controller;

use Symfony\Component\HttpFoundation\Request;
use Faithlead\RestBundle\Form\Type\UserType;

use FOS\RestBundle\Controller\Annotations\View,
    FOS\RestBundle\Controller\FOSRestController,
    FOS\RestBundle\Controller\Annotations\RouteResource;

use Faithlead\RestBundle\Document\User;

use Nelmio\ApiDocBundle\Annotation\ApiDoc;

/**
 * Class UserController
 * @package Faithlead\Bundle\RestBundle\Controller
 * @RouteResource("User")
 */

class UserController extends FosRestController
{

    /**
     * Get the list of all User
     *
     * @return array data
     *
     * @View()
     * @ApiDoc()
     */
    public function allAction()
    {
        $data = array();
        $dm                      = $this->get('doctrine.odm.mongodb.document_manager');
        $userRepository          = $dm->getRepository('FaithleadRestBundle:User');
        $userEntities            = $userRepository->findAll();

        $cnt = 0;
        foreach($userEntities as $userEntity)
        {
            $result = array(
            'id'            => $userEntity->getId(),
            'first_name'    => $userEntity->getFirstName(),
            'last_name'     => $userEntity->getLastName(),
            'email'         => $userEntity->getEmail(),
            'success'       => true
            );

            $data[$cnt++] = $result;
        }

        return $data;
    }



    /**
     * Get the list of users
     *
     * @param int $id
     * @return array data
     *
     * @View()
     * @ApiDoc()
     */
    public function getAction($id)
    {

        $repository = $this->get('doctrine.odm.mongodb.document_manager')
            ->getRepository('FaithleadRestBundle:User');
        $user = $repository->findOneById($id);

        return array('users' => array(
            'id' => $user->getId(),
            'First Name' => $user->getFirstName(),
            'Last Name' => $user->getLastName(),
            'email' => $user->getEmail()
        ));
    }

    /**
     * @View()
     * @ApiDoc(
     *      description="Register new user account.",
     *      input="Faithlead\RestBundle\Form\Type\UserType",
     *      output="Faithlead\RestBundle\Document\User",
     *      statusCodes={
     *         200="Returned when successful and return created User Id"
     *     }
     *
     * )
     */

    public function postAction(Request $request){

        $dm = $this->get('doctrine.odm.mongodb.document_manager');

        $user = new User();

        $form = $this->getForm($user);<commit_msg>404 error message added<commit_after><?php

namespace Faithlead\RestBundle\Controller;

use Symfony\Component\HttpFoundation\Request;
use Faithlead\RestBundle\Form\Type\UserType;

use FOS\RestBundle\Controller\Annotations\View,
    FOS\RestBundle\Controller\FOSRestController,
    FOS\RestBundle\Controller\Annotations\RouteResource;

use Faithlead\RestBundle\Document\User;

use Nelmio\ApiDocBundle\Annotation\ApiDoc;

/**
 * Class UserController
 * @package Faithlead\Bundle\RestBundle\Controller
 * @RouteResource("User")
 */

class UserController extends FosRestController
{

    /**
     * Get the list of all User
     *
     * @return array data
     *
     * @View()
     * @ApiDoc()
     */
    public function allAction()
    {
        $data = array();
        $dm                      = $this->get('doctrine.odm.mongodb.document_manager');
        $userRepository          = $dm->getRepository('FaithleadRestBundle:User');
        $userEntities            = $userRepository->findAll();

        $cnt = 0;
        foreach($userEntities as $userEntity)
        {
            $result = array(
            'id'            => $userEntity->getId(),
            'first_name'    => $userEntity->getFirstName(),
            'last_name'     => $userEntity->getLastName(),
            'email'         => $userEntity->getEmail(),
            'success'       => true
            );

            $data[$cnt++] = $result;
        }

        return $data;
    }



    /**
     * Get the list of users
     *
     * @param int $id
     * @return array data
     *
     * @View()
     * @ApiDoc()
     */
    public function getAction($id)
    {

        $repository = $this->get('doctrine.odm.mongodb.document_manager')
            ->getRepository('FaithleadRestBundle:User');
        $user = $repository->findOneById($id);

        return array('users' => array(
            'id' => $user->getId(),
            'First Name' => $user->getFirstName(),
            'Last Name' => $user->getLastName(),
            'email' => $user->getEmail()
        ));
    }

    /**
     * @View()
     * @ApiDoc(
     *      description="Register new user account.",
     *      input="Faithlead\RestBundle\Form\Type\UserType",
     *      output="Faithlead\RestBundle\Document\User",
     *      statusCodes={
     *         200="Returned when successful and return created User Id",
     *         404="ERROR message"
     *     }
     *
     * )
     */

    public function postAction(Request $request){

        $dm = $this->get('doctrine.odm.mongodb.document_manager');

        $user = new User();

        $form = $this->getForm($user);
{'fraction_non_alphanumeric': 0.14162182936202922, 'fraction_numerical': 0.002690238278247502, 'mean_word_length': 2.0017301038062283, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 55, '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': '1885135', 'n_tokens_mistral': 1567, 'n_tokens_neox': 1510, 'n_words': 262}