<commit_before><?php
namespace Mrimann\AngularDemo\Controller;

/*                                                                        *
 * This script belongs to the TYPO3 Flow package "Mrimann.AngularDemo".   *
 *                                                                        *
 *                                                                        */

use Mrimann\AngularDemo\Domain\Model\Idea;
use TYPO3\Flow\Annotations as Flow;

class ApiController extends \TYPO3\Flow\Mvc\Controller\RestController {

	protected $defaultViewObjectName = 'TYPO3\\Flow\\Mvc\\View\\JsonView';

	protected $resourceArgumentName = 'idea';

	/**
	 * @var \Mrimann\AngularDemo\Domain\Repository\IdeaRepository
	 * @Flow\Inject
	 */
	protected $ideaRepository;

	/**
	 * Returns all the ideas that are already stored in the database
	 */
	public function listAction() {
		$this->view->setVariablesToRender(array('ideas'));

		$ideas = $this->ideaRepository->findAll();
		$this->view->assign('ideas', $ideas);
	}

	/**
	 * @param \Mrimann\AngularDemo\Domain\Model\Idea $idea
	 */
	public function deleteAction(\Mrimann\AngularDemo\Domain\Model\Idea $idea) {
		$this->ideaRepository->remove($idea);
	}

	/**
	 * Surround the initialize action from the parent controller
	 */
	public function initializeCreateAction() {
		// noop
	}

	/**
	 * Create + Store a new idea
	 *
	 * @param void
	 */
	public function createAction() {
		$idea = new Idea();

		$data = $this->request->getArgument('idea');
		$idea->setName($data['name']);

		$this->ideaRepository->add($idea);<commit_msg>[FEATURE] Use the property mapper from the RestController<commit_after><?php
namespace Mrimann\AngularDemo\Controller;

/*                                                                        *
 * This script belongs to the TYPO3 Flow package "Mrimann.AngularDemo".   *
 *                                                                        *
 *                                                                        */

use Mrimann\AngularDemo\Domain\Model\Idea;
use TYPO3\Flow\Annotations as Flow;

class ApiController extends \TYPO3\Flow\Mvc\Controller\RestController {

	protected $defaultViewObjectName = 'TYPO3\\Flow\\Mvc\\View\\JsonView';

	protected $resourceArgumentName = 'idea';

	/**
	 * @var \Mrimann\AngularDemo\Domain\Repository\IdeaRepository
	 * @Flow\Inject
	 */
	protected $ideaRepository;

	/**
	 * Returns all the ideas that are already stored in the database
	 */
	public function listAction() {
		$this->view->setVariablesToRender(array('ideas'));

		$ideas = $this->ideaRepository->findAll();
		$this->view->assign('ideas', $ideas);
	}

	/**
	 * @param \Mrimann\AngularDemo\Domain\Model\Idea $idea
	 */
	public function deleteAction(\Mrimann\AngularDemo\Domain\Model\Idea $idea) {
		$this->ideaRepository->remove($idea);
	}

	/**
	 * Create + Store a new idea
	 *
	 * @param \Mrimann\AngularDemo\Domain\Model\Idea $idea
	 * @param void
	 */
	public function createAction(\Mrimann\AngularDemo\Domain\Model\Idea $idea) {
		$this->ideaRepository->add($idea);
{'fraction_non_alphanumeric': 0.12884238064094178, 'fraction_numerical': 0.002616088947024199, 'mean_word_length': 2.2404661016949152, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5715871', 'n_tokens_mistral': 923, 'n_tokens_neox': 852, 'n_words': 170}