<commit_before><?php
/**
 * Created by PhpStorm.
 * User: sjoder
 * Date: 01.12.2016
 * Time: 16:05
 */

namespace PM\Bundle\ToolBundle\Framework\Traits\Controller;

/**
 * Class DoctrineTrait
 *
 * @package PM\Bundle\ToolBundle\Framework\Traits\Controller
 */
trait HasDoctrineControllerTrait
{
    /**
     * Persist and Flush
     *
     * @param mixed $entity
     *
     * @return $this
     */
    public function persistAndFlush($entity)
    {
        $this->getDoctrine()->getManager()->persist($entity);
        $this->getDoctrine()->getManager()->flush();

        return $this;
    }
}<commit_msg>part of #7<commit_after><?php
/**
 * Created by PhpStorm.
 * User: sjoder
 * Date: 01.12.2016
 * Time: 16:05
 */

namespace PM\Bundle\ToolBundle\Framework\Traits\Controller;

/**
 * Class DoctrineTrait
 *
 * @package PM\Bundle\ToolBundle\Framework\Traits\Controller
 */
trait HasDoctrineControllerTrait
{
    /**
     * Persist and Flush
     *
     * @return $this
     */
    public function persistAndFlush()
    {
        if (0 === func_num_args()) {
            throw new \LogicException('Missing arguments');
        }

        $persists = [];
        $entities = func_get_args();

        foreach ($entities as $entity) {
            if (true === is_array($entity)) {
                $persists = array_merge($persists, $entity);
            } else {
                $persists[] = $entity;
            }
        }

        foreach ($persists as $persist) {
            $this->getDoctrine()->getManager()->persist($persist);
        }

        $this->getDoctrine()->getManager()->flush();

        return $this;
    }
}
{'fraction_non_alphanumeric': 0.15012254901960784, 'fraction_numerical': 0.015931372549019607, 'mean_word_length': 2.2209072978303745, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '1690382', 'n_tokens_mistral': 527, 'n_tokens_neox': 503, 'n_words': 92}