Manufacturer.php (5231B)
1 <?php 2 3 namespace PartKeepr\ManufacturerBundle\Entity; 4 5 use Doctrine\Common\Collections\ArrayCollection; 6 use Doctrine\ORM\Mapping as ORM; 7 use PartKeepr\CoreBundle\Entity\BaseEntity; 8 use PartKeepr\DoctrineReflectionBundle\Annotation\TargetService; 9 use PartKeepr\UploadedFileBundle\Annotation\UploadedFileCollection; 10 use Symfony\Component\Serializer\Annotation\Groups; 11 12 /** 13 * Represents a manufacturer. 14 * 15 * @ORM\Entity 16 * @TargetService(uri="/api/manufacturers") 17 **/ 18 class Manufacturer extends BaseEntity 19 { 20 /** 21 * The name of the manufacturer. 22 * 23 * @ORM\Column(type="string",unique=true) 24 * @Groups({"default"}) 25 * 26 * @var string 27 */ 28 private $name; 29 30 /** 31 * The address of the manufacturer. 32 * 33 * @ORM\Column(type="text",nullable=true) 34 * @Groups({"default"}) 35 * 36 * @var string 37 */ 38 private $address; 39 40 /** 41 * The URL. 42 * 43 * @ORM\Column(type="string",nullable=true) 44 * @Groups({"default"}) 45 * 46 * @var string 47 */ 48 private $url; 49 50 /** 51 * The email. 52 * 53 * @ORM\Column(type="string",nullable=true) 54 * @Groups({"default"}) 55 * 56 * @var string 57 */ 58 private $email; 59 60 /** 61 * The comment. 62 * 63 * @ORM\Column(type="text",nullable=true) 64 * @Groups({"default"}) 65 * 66 * @var string 67 */ 68 private $comment; 69 70 /** 71 * The phone number. 72 * 73 * @ORM\Column(type="string",nullable=true) 74 * @Groups({"default"}) 75 * 76 * @var string 77 */ 78 private $phone; 79 80 /** 81 * The fax number. 82 * 83 * @ORM\Column(type="string",nullable=true) 84 * @Groups({"default"}) 85 * 86 * @var string 87 */ 88 private $fax; 89 90 /** 91 * All ic logos of this manufacturer. 92 * 93 * @ORM\OneToMany(targetEntity="PartKeepr\ManufacturerBundle\Entity\ManufacturerICLogo",mappedBy="manufacturer",cascade={"persist", "remove"}, orphanRemoval=true) 94 * 95 * @UploadedFileCollection() 96 * @Groups({"default"}) 97 */ 98 private $icLogos; 99 100 /** 101 * Creates a new manufacturer instance. 102 */ 103 public function __construct() 104 { 105 $this->icLogos = new ArrayCollection(); 106 } 107 108 /** 109 * Sets the name. 110 * 111 * @param string $name The name 112 */ 113 public function setName($name) 114 { 115 $this->name = $name; 116 } 117 118 /** 119 * Returns the name. 120 * 121 * @return string The name 122 */ 123 public function getName() 124 { 125 return $this->name; 126 } 127 128 /** 129 * Sets the phone number. 130 * 131 * @param string $phone The phone number 132 */ 133 public function setPhone($phone) 134 { 135 $this->phone = $phone; 136 } 137 138 /** 139 * Returns the phone number. 140 * 141 * @return string The phone number 142 */ 143 public function getPhone() 144 { 145 return $this->phone; 146 } 147 148 /** 149 * Sets the fax number. 150 * 151 * @param string $fax The fax number 152 */ 153 public function setFax($fax) 154 { 155 $this->fax = $fax; 156 } 157 158 /** 159 * Returns the fax number. 160 * 161 * @return string The fax number 162 */ 163 public function getFax() 164 { 165 return $this->fax; 166 } 167 168 /** 169 * Sets the address. 170 * 171 * @param string $address The address 172 */ 173 public function setAddress($address) 174 { 175 $this->address = $address; 176 } 177 178 /** 179 * Returns the address. 180 * 181 * @return string The address 182 */ 183 public function getAddress() 184 { 185 return $this->address; 186 } 187 188 /** 189 * Sets the comment. 190 * 191 * @param string $comment The comment 192 */ 193 public function setComment($comment) 194 { 195 $this->comment = $comment; 196 } 197 198 /** 199 * Returns the comment. 200 * 201 * @return string The comment 202 */ 203 public function getComment() 204 { 205 return $this->comment; 206 } 207 208 /** 209 * Sets the email. 210 * 211 * @param string $email The email 212 */ 213 public function setEmail($email) 214 { 215 $this->email = $email; 216 } 217 218 /** 219 * Returns the email. 220 * 221 * @return string The email 222 */ 223 public function getEmail() 224 { 225 return $this->email; 226 } 227 228 /** 229 * Sets the URL. 230 * 231 * @param string $url The URL 232 */ 233 public function setURL($url) 234 { 235 $this->url = $url; 236 } 237 238 /** 239 * Returns the URL. 240 * 241 * @return string The url 242 */ 243 public function getURL() 244 { 245 return $this->url; 246 } 247 248 /** 249 * Returns the ic logos. 250 * 251 * @return ArrayCollection The array with all ic logos 252 */ 253 public function getIcLogos() 254 { 255 return $this->icLogos->getValues(); 256 } 257 258 /** 259 * Adds an IC Logo. 260 * 261 * @param object $icLogo Either a ManufacturerICLogo or a TempImage 262 */ 263 public function addIcLogo($icLogo) 264 { 265 if ($icLogo instanceof ManufacturerICLogo) { 266 $icLogo->setManufacturer($this); 267 } 268 269 $this->icLogos->add($icLogo); 270 } 271 272 /** 273 * Removes an IC Logo. 274 * 275 * @param ManufacturerICLogo $icLogo 276 */ 277 public function removeIcLogo(ManufacturerICLogo $icLogo) 278 { 279 $icLogo->setManufacturer(null); 280 $this->icLogos->removeElement($icLogo); 281 } 282 }