src/JuridicusBundle/Entity/Export.php line 12

Open in your IDE?
  1. <?php
  2. namespace JF\JuridicusBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Validator\Constraints as Assert;
  5. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  6. /**
  7.  * Export
  8.  */
  9. class Export extends InitModeEntity
  10. {
  11.     const CLASSNAME __CLASS__;
  12.     
  13.     /**
  14.      * @var integer
  15.      */
  16.     private $id;
  17.     /**
  18.      * @var integer
  19.      * @Assert\Type(type="integer")
  20.      * @Assert\NotNull
  21.      * @Assert\Range(min="1")
  22.      */
  23.     private $anzahl;
  24.     /**
  25.      * @var \DateTime
  26.      * @Assert\Type(\DateTimeInterface::class)
  27.      */
  28.     private $created_at;
  29.     /**
  30.      * @var \JF\JuridicusBundle\Entity\Partner
  31.      * @Assert\Valid
  32.      */
  33.     private $partner;
  34.     /**
  35.      * @var \Doctrine\Common\Collections\Collection
  36.      */
  37.     private $kunden;
  38.     /**
  39.      * @var integer
  40.      */
  41.     private $examen;
  42.     /**
  43.      * Constructor
  44.      */
  45.     public function __construct()
  46.     {
  47.         $this->kunden = new \Doctrine\Common\Collections\ArrayCollection();
  48.     }
  49.     
  50.     /**
  51.      * Get id
  52.      *
  53.      * @return integer 
  54.      */
  55.     public function getId()
  56.     {
  57.         return $this->id;
  58.     }
  59.     /**
  60.      * Set created_at
  61.      *
  62.      * @param \DateTime $createdAt
  63.      * @return Export
  64.      */
  65.     public function setCreatedAt($createdAt)
  66.     {
  67.         $this->created_at $createdAt;
  68.     
  69.         return $this;
  70.     }
  71.     /**
  72.      * Get created_at
  73.      *
  74.      * @return \DateTime 
  75.      */
  76.     public function getCreatedAt()
  77.     {
  78.         return $this->created_at;
  79.     }
  80.     /**
  81.      * Get created_at
  82.      *
  83.      * @return \DateTime 
  84.      */
  85.     public function getListString()
  86.     {
  87.         return sprintf'%d Kunden am %s',     $this->anzahl
  88.             $this->created_at $this->created_at->format('d.m.Y H:i:s') : '(Datum unbekannt)'
  89.         );    
  90.     }
  91.     
  92.     /**
  93.      * Set partner [OWNING SIDE]
  94.      *
  95.      * @param \JF\JuridicusBundle\Entity\Partner $partner
  96.      * @return Export
  97.      */
  98.     public function setPartner(\JF\JuridicusBundle\Entity\Partner $partner null)
  99.     {
  100.         $this->partner $partner;
  101.     
  102.         return $this;
  103.     }
  104.     /**
  105.      * Get partner
  106.      *
  107.      * @return \JF\JuridicusBundle\Entity\Partner 
  108.      */
  109.     public function getPartner()
  110.     {
  111.         return $this->partner;
  112.     }
  113.     /**
  114.      * Add kunden [OWNINGS SIDE]
  115.      *
  116.      * @param \JF\JuridicusBundle\Entity\Kunde $kunden
  117.      * @return Export
  118.      */
  119.     public function addKunden(\JF\JuridicusBundle\Entity\Kunde $kunden NULL)
  120.     {
  121.         $this->kunden[] = $kunden;
  122.         $kunden->addExporte($this);
  123.         
  124.         return $this;
  125.     }
  126.     /**
  127.      * Remove kunden
  128.      *
  129.      * @param \JF\JuridicusBundle\Entity\Kunde $kunden
  130.      */
  131.     public function removeKunden(\JF\JuridicusBundle\Entity\Kunde $kunden)
  132.     {
  133.         $this->kunden->removeElement($kunden);
  134.         $kunden->removeExporte($this);
  135.     }
  136.     /**
  137.      * Get kunden
  138.      *
  139.      * @return \Doctrine\Common\Collections\Collection 
  140.      */
  141.     public function getKunden()
  142.     {
  143.         return $this->kunden;
  144.     }
  145.    
  146.     /**
  147.      * Set anzahl
  148.      *
  149.      * @param integer $anzahl
  150.      * @return Export
  151.      */
  152.     public function setAnzahl($anzahl)
  153.     {
  154.         $this->anzahl $anzahl;
  155.     
  156.         return $this;
  157.     }
  158.     /**
  159.      * Get anzahl
  160.      *
  161.      * @return integer 
  162.      */
  163.     public function getAnzahl()
  164.     {
  165.         return $this->anzahl;
  166.     }
  167.     /**
  168.      * @ORM\PrePersist
  169.      */
  170.     public function setCreatedAtValue()
  171.     {
  172.         if (!$this->init_mode AND !isset($this->created_at))
  173.         {
  174.             $this->setCreatedAt(new \DateTime());
  175.         }       
  176.     }
  177.   
  178.     /**
  179.      * Set examen
  180.      *
  181.      * @param integer $examen
  182.      * @return Export
  183.      */
  184.     public function setExamen($examen)
  185.     {
  186.         $this->examen $examen;
  187.     
  188.         return $this;
  189.     }
  190.     /**
  191.      * Get examen
  192.      *
  193.      * @return integer 
  194.      */
  195.     public function getExamen()
  196.     {
  197.         return $this->examen;
  198.     }
  199.     
  200.     public function __toString()
  201.     {
  202.         if (isset($this->id))
  203.         {
  204.             if (isset($this->created_at))
  205.             {
  206.                 return sprintf('%s - %s'$this->created_at->format('d.m.Y H:i:s'), $this->getPartner()->getName());
  207.             }
  208.             else 
  209.             {
  210.                 return $this->getPartner()->getName();
  211.             }
  212.         }
  213.         return 'Neuer Export';    
  214.     }
  215. }