<commit_before><?php

/*
 * This file is part of the Incipio package.
 *
 * (c) <NAME>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace mgate\SuiviBundle\Manager;

use Doctrine\ORM\EntityManager;

class DocTypeManager /*extends \Twig_Extension*/
{
    protected $em;

    public function __construct(EntityManager $em)
    {
        $this->em = $em;
    }

    // Pour utiliser les fonctions depuis twig
    public function getName()
    {
        return 'mgate_DocTypeManager';
    }
    // Pour utiliser les fonctions depuis twig
    public function getFunctions()
    {
        return array();
    }

    public function getRepository()
    {
        return $this->em->getRepository('mgateSuiviBundle:Etude');
    }

    public function checkSaveNewEmploye($doc)
    {
        if (!$doc->isKnownSignataire2()) {
            $doc->setSignataire2($doc->getNewSignataire2()->getPersonne());

            $doc->getNewSignataire2()->setProspect($doc->getEtude()->getProspect());
            $this->em->persist($doc->getNewSignataire2());
        }
    }
}<commit_msg>Modification of DoctypeManager to make inline employee creation (with Ap) compatible with new conditions between Personne and Employe<commit_after><?php

/*
 * This file is part of the Incipio package.
 *
 * (c) <NAME>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace mgate\SuiviBundle\Manager;

use Doctrine\ORM\EntityManager;
use mgate\SuiviBundle\Entity\DocType;

class DocTypeManager /*extends \Twig_Extension*/
{
    protected $em;

    public function __construct(EntityManager $em)
    {
        $this->em = $em;
    }

    // Pour utiliser les fonctions depuis twig
    public function getName()
    {
        return 'mgate_DocTypeManager';
    }
    // Pour utiliser les fonctions depuis twig
    public function getFunctions()
    {
        return array();
    }

    public function getRepository()
    {
        return $this->em->getRepository('mgateSuiviBundle:Etude');
    }

    public function checkSaveNewEmploye(DocType $doc)
    {
        if (!$doc->isKnownSignataire2()) {
            $employe = $doc->getNewSignataire2();
            $this->em->persist($employe->getPersonne());
            $employe->setProspect($doc->getEtude()->getProspect());
            $employe->getPersonne()->setEmploye($employe);
            $this->em->persist($employe);

            $doc->setSignataire2($employe->getPersonne());

        }
    }
}
{'fraction_non_alphanumeric': 0.11981566820276497, 'fraction_numerical': 0.0030721966205837174, 'mean_word_length': 2.825256975036711, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 36, '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': '5505', 'n_tokens_mistral': 789, 'n_tokens_neox': 762, 'n_words': 186}