src/Entity/OffreAccueil/PreferencesPublication.php line 197

Open in your IDE?
  1. <?php
  2. namespace App\Entity\OffreAccueil;
  3. use \JsonSerializable;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. /**
  7.  * @ORM\Entity
  8.  * @ORM\Table(name="efc.oa_preferences_publication")
  9.  */
  10. class PreferencesPublication implements JsonSerializable
  11. {
  12.     use \App\Entity\Commun\IdTrait;
  13.     /**
  14.      * @Assert\NotNull()
  15.      * @ORM\OneToOne(targetEntity="App\Entity\AssistantMaternel\AssistantMaternel", inversedBy="preferences_publication")
  16.      * @ORM\JoinColumn(name="id_assmat", referencedColumnName="id", nullable=false)
  17.      */
  18.     private $assmat;
  19.     /**
  20.      * @ORM\Column(type="boolean", nullable=true, options={"default":null})
  21.      */
  22.     private $publi_age;
  23.     /**
  24.      * @ORM\Column(type="boolean", nullable=true, options={"default":null})
  25.      */
  26.     private $publi_enfants_assmat;
  27.     /**
  28.      * @ORM\Column(type="boolean", nullable=true, options={"default":null})
  29.      */
  30.     private $publi_tel_fixe;
  31.     /**
  32.      * @ORM\Column(type="boolean", nullable=true, options={"default":null})
  33.      */
  34.     private $publi_tel_portable;
  35.     /**
  36.      * @ORM\Column(type="boolean", nullable=true, options={"default":null})
  37.      */
  38.     private $publi_email;
  39.     use \App\Entity\Commun\DateCreationTrait;
  40.     use \App\Entity\Commun\DateModificationTrait;
  41.     /**
  42.      * Get assmat
  43.      *
  44.      * @return Assmat
  45.      */
  46.     public function getAssmat()
  47.     {
  48.         return $this->assmat;
  49.     }
  50.     /**
  51.      * Set assmat
  52.      *
  53.      * @param Assmat $assmat
  54.      * 
  55.      * @return PreferencesPublication
  56.      */
  57.     public function setAssmat(\App\Entity\AssistantMaternel\AssistantMaternel $assmat)
  58.     {
  59.         $this->assmat $assmat;
  60.         return $this;
  61.     }
  62.     /**
  63.      * Get publi_age
  64.      *
  65.      * @return boolean
  66.      */
  67.     public function getPubliAge()
  68.     {
  69.         return $this->publi_age;
  70.     }
  71.     /**
  72.      * Set publi_age
  73.      *
  74.      * @param boolean $publi_age
  75.      * 
  76.      * @return PreferencesPublication
  77.      */
  78.     public function setPubliAge(bool $publi_age)
  79.     {
  80.         $this->publi_age $publi_age;
  81.         return $this;
  82.     }
  83.     /**
  84.      * Get publi_enfants_assmat
  85.      *
  86.      * @return boolean
  87.      */
  88.     public function getPubliEnfantsAssmat()
  89.     {
  90.         return $this->publi_enfants_assmat;
  91.     }
  92.     /**
  93.      * Set publi_enfants_assmat
  94.      *
  95.      * @param boolean $publi_enfants_assmat
  96.      * 
  97.      * @return PreferencesPublication
  98.      */
  99.     public function setPubliEnfantsAssmat(bool $publi_enfants_assmat)
  100.     {
  101.         $this->publi_enfants_assmat $publi_enfants_assmat;
  102.         return $this;
  103.     }
  104.     /**
  105.      * Get publi_tel_fixe
  106.      *
  107.      * @return boolean
  108.      */
  109.     public function getPubliTelFixe()
  110.     {
  111.         return $this->publi_tel_fixe;
  112.     }
  113.     /**
  114.      * Set publi_tel_fixe
  115.      *
  116.      * @param boolean $publi_tel_fixe
  117.      * 
  118.      * @return PreferencesPublication
  119.      */
  120.     public function setPubliTelFixe(bool $publi_tel_fixe)
  121.     {
  122.         $this->publi_tel_fixe $publi_tel_fixe;
  123.         return $this;
  124.     }
  125.     /**
  126.      * Get publi_tel_portable
  127.      *
  128.      * @return boolean
  129.      */
  130.     public function getPubliTelPortable()
  131.     {
  132.         return $this->publi_tel_portable;
  133.     }
  134.     /**
  135.      * Set publi_tel_portable
  136.      *
  137.      * @param boolean $publi_tel_portable
  138.      * 
  139.      * @return PreferencesPublication
  140.      */
  141.     public function setPubliTelPortable(bool $publi_tel_portable)
  142.     {
  143.         $this->publi_tel_portable $publi_tel_portable;
  144.         return $this;
  145.     }
  146.     /**
  147.      * Get publi_email
  148.      *
  149.      * @return boolean
  150.      */
  151.     public function getPubliEmail()
  152.     {
  153.         return $this->publi_email;
  154.     }
  155.     /**
  156.      * Set publi_email
  157.      *
  158.      * @param boolean $publi_email
  159.      * 
  160.      * @return PreferencesPublication
  161.      */
  162.     public function setPubliEmail(bool $publi_email)
  163.     {
  164.         $this->publi_email $publi_email;
  165.         return $this;
  166.     }
  167.     /*
  168.      * Implémentation de JsonSerializable
  169.      * Ne liste que les champs modifiables par les utilisateurs
  170.      */
  171.     public function jsonSerialize()
  172.     {
  173.         return [
  174.             'publi_age' => $this->publi_age,
  175.             'publi_email' => $this->publi_email,
  176.             'publi_enfants_assmat' => $this->publi_enfants_assmat,
  177.             'publi_tel_fixe' => $this->publi_tel_fixe,
  178.             'publi_tel_portable' => $this->publi_tel_portable,
  179.         ];
  180.     }
  181.     /**
  182.      * Obtient une nouvelle instance de PreferencesPublication, initialisée à partir du tableau associatif fourni en paramètre
  183.      *
  184.      * @param array $data
  185.      * @return PreferencesPublication
  186.      */
  187.     public static function createFromArray(array $data)
  188.     {
  189.         $newInstance = new PreferencesPublication();
  190.         return $newInstance->initFromArray($data);
  191.     }
  192.     public static function createFromAssmat(\App\Entity\AssistantMaternel\AssistantMaternel $assmat): PreferencesPublication
  193.     {
  194.         $pref = new PreferencesPublication();
  195.         $pref->setDateCreation(new \DateTime());
  196.         $pref->setAssmat($assmat);
  197.         // Afficher les infos si assmat n'est pas opposé
  198.         $defaut = !$assmat->getOppose();
  199.         $pref->setPubliAge($defaut);
  200.         $pref->setPubliEnfantsAssmat($defaut);
  201.         // Pour les téléphones, afficher infos si assmat n'est pas opposé ET n'est pas sur liste rouge
  202.         $pref->setPubliTelFixe($assmat->getPublieTelFixeEtendu());
  203.         $pref->setPubliTelPortable($assmat->getPublieTelPortableEtendu());
  204.         $pref->setPubliEmail($assmat->getPublieMailEtendu());
  205.         return $pref;
  206.     }
  207.     /**
  208.      * mappe les propriétés sur l'instance à partir d'un tableau associatif
  209.      *
  210.      * @param array $data
  211.      * @return void
  212.      */
  213.     public function initFromArray(array $data)
  214.     {
  215.         foreach ($data as $prop => $value) {
  216.             $this->{$prop} = $value;
  217.         }
  218.         return $this;
  219.     }
  220. }