| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Bludata\Doctrine\ORM\Entities; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Bludata\Doctrine\Common\Interfaces\BaseEntityInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Bludata\Doctrine\Common\Interfaces\EntityTimestampInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Bludata\Doctrine\Common\Traits\SetPropertiesEntityTrait; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use DateTime; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Doctrine\Common\Collections\ArrayCollection; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Doctrine\ORM\Mapping as ORM; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Doctrine\ORM\PersistentCollection; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use EntityManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Gedmo\Mapping\Annotation as Gedmo; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * @ORM\MappedSuperclass | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * @ORM\HasLifecycleCallbacks | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | abstract class BaseEntity implements BaseEntityInterface, EntityTimestampInterface | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     use SetPropertiesEntityTrait; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |      * @ORM\Id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |      * @ORM\Column(type="integer", name="id") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |      * @ORM\GeneratedValue | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     protected $id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |      * @var \DateTime | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      * @Gedmo\Timestampable(on="create") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      * @ORM\Column(type="datetime", name="createdAt") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     private $createdAt; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      * @var \DateTime | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      * @Gedmo\Timestampable(on="update") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |      * @ORM\Column(type="datetime", name="updatedAt") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     private $updatedAt; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      * @ORM\Column(type="datetime", nullable=true, name="deletedAt") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     private $deletedAt; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     public function getCreatedAt() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         return $this->createdAt; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     public function getUpdatedAt() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         return $this->updatedAt; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     public function getDeletedAt() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         return $this->deletedAt; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     public function setDeletedAt($deletedAt) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         $this->deletedAt = $deletedAt; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     public function getDiscr() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |         return $this->getRepository()->getClassMetadata()->discriminatorValue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     public function getDiscrName() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         return $this->getRepository()->getClassMetadata()->discriminatorColumn['name']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |      * Altera o campo updatedAt para forçar o persist da entity. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     public function forcePersist() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |         $this->updatedAt = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |      * @ORM\PrePersist | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |     public function prePersist() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |         $this->getRepository() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |              ->preSave($this) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |              ->validate($this); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |      * @ORM\PostPersist | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |     public function postPersist() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |         $this->getRepository() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |              ->postSave($this); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |      * @ORM\PreUpdate | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |     public function preUpdate() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |         $this->getRepository() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |              ->preSave($this) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |              ->validate($this); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |      * @ORM\PostUpdate | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |     public function postUpdate() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |         $this->getRepository() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |              ->postSave($this); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |     public function getRepository() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |         return EntityManager::getRepository(get_class($this)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |     public function remove() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |         $this->getRepository()->remove($this); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |     public function save($flush = false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |         $this->getRepository()->save($this); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |     public function flush($all = true) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |         $this->getRepository()->flush($all ? null : $this); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |     public function getId() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |         return $this->id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |     protected function getFillable() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |         return ['id', 'createdAt', 'updatedAt', 'deletedAt']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |      * Retona um array com o nome das propriedade que o cliente pode setar para realizar o store | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |      * É usado principalmente em $this->setPropertiesEntity e nos Controllers. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |      * Este método não evita que uma propriedade seja alterada caso tenha seu método set(). | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |     abstract public function getOnlyStore(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |      * Retona um array com o nome das propriedade que o cliente pode setar para realizar o update. | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |      * Por padrão retorna os mesmos valores de $this->getOnlyStore(). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |      * Este método pode ser sobrescrito nas classes filhas. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |      * É usado principalmente em $this->setPropertiesEntity e nos Controllers. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |      * Este método não evita que uma propriedade seja alterada caso tenha seu método set(). | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |      * @return array | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 183 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 184 |  |  |     public function getOnlyUpdate() | 
            
                                                                        
                            
            
                                    
            
            
                | 185 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 186 |  |  |         return $this->getOnlyStore(); | 
            
                                                                        
                            
            
                                    
            
            
                | 187 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 189 |  | View Code Duplication |     final protected function checkOnyExceptInArray($key, array $options = null) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |         if ( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |             $options | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |             && | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |             ( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |                 (isset($options['only']) && is_array($options['only']) && !in_array($key, $options['only'])) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |                 || | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |                 (isset($options['except']) && is_array($options['except']) && in_array($key, $options['except'])) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |         ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |             return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |         return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |     public function toArray(array $options = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |         $classMetadata = $this->getRepository()->getClassMetadata(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |         $array = []; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |         foreach ($this->getFillable() as $key) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |             $metaDataKey = $classMetadata->hasField($key) ? $classMetadata->getFieldMapping($key) : null; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |             if ($this->checkOnyExceptInArray($key, $options)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |                 if (is_object($this->$key)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |                     if ($this->$key instanceof DateTime) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |                         if ($this->$key) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |                             $dateFormat = 'Y-m-d'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |                             if ($metaDataKey) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |                                 switch ($metaDataKey['type']) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |                                     case 'datetime': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |                                         $dateFormat = 'Y-m-d H:i:s'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |                                         break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |                                     case 'time': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |                                         $dateFormat = 'H:i:s'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |                                         break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |                                     default: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |                                         break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |                                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |                             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |                             $array[$key] = $this->$key->format($dateFormat); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |                         } | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 236 |  | View Code Duplication |                     } elseif ($this->$key instanceof ArrayCollection || $this->$key instanceof PersistentCollection) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |                         $ids = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |                         foreach ($this->$key->getValues() as $item) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |                             $ids[] = $item->getId(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |                         $array[$key] = $ids; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |                     } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |                         $array[$key] = $this->$key->getId(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |                 } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |                     if ($metaDataKey['type'] == 'decimal') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |                         $array[$key] = (float) $this->$key; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |                     } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |                         $array[$key] = $this->$key; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |         return $array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 257 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 258 |  |  |  | 
            
                        
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.