Created
October 31, 2012 11:50
-
-
Save micheleorselli/3986640 to your computer and use it in GitHub Desktop.
one line getter setter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Ideato\OfferBundle\Entity; | |
use FOS\UserBundle\Entity\User as BaseUser; | |
use Doctrine\ORM\Mapping as ORM; | |
use Doctrine\Common\Collections\ArrayCollection; | |
use Symfony\Component\Validator\Constraints as Assert; | |
use Symfony\Component\HttpFoundation\File\UploadedFile; | |
use Symfony\Component\Validator\ExecutionContext; | |
use Symfony\Component\HttpFoundation\File\File; | |
use Vich\UploaderBundle\Mapping\Annotation as Vich; | |
use Ideato\OfferBundle\Serializer\JsonSerializer; | |
/** | |
* @ORM\Entity(repositoryClass="Ideato\OfferBundle\Repository\CompanyRepository") | |
* @ORM\Table(name="company") | |
*/ | |
class Company | |
{ | |
/** | |
* @ORM\Id | |
* @ORM\Column(type="integer") | |
* @ORM\GeneratedValue(strategy="AUTO") | |
*/ | |
protected $id; | |
/** | |
* @ORM\Column(name="name", type="string", length=255) | |
* @Assert\NotBlank() | |
*/ | |
private $name; | |
/** | |
* @Assert\File( | |
* maxSize="2M", | |
* mimeTypes={"image/png", "image/jpeg", "image/pjpeg"} | |
* ) | |
* @Vich\UploadableField(mapping="company", fileNameProperty="picture_name") | |
* | |
* @var File $picture | |
*/ | |
protected $picture; | |
/** | |
* @ORM\Column(name="picture_name", type="string", length=255, nullable=true) | |
*/ | |
protected $picture_name; | |
/** | |
* @ORM\Column(name="address", type="string", length=255) | |
* @Assert\NotBlank() | |
*/ | |
private $address; | |
/** | |
* @ORM\Column(name="phone", type="string", length=30) | |
* @Assert\NotBlank() | |
*/ | |
private $phone; | |
/** | |
* @ORM\Column(name="web", type="string", length=255) | |
* @Assert\NotBlank() | |
*/ | |
private $web; | |
/** | |
* @ORM\Column(name="email", type="string", length=255) | |
* @Assert\NotBlank() | |
*/ | |
private $email; | |
/** | |
* @ORM\Column(type="string", length=255) | |
*/ | |
protected $latitude; | |
/** | |
* @ORM\Column(type="string", length=255) | |
*/ | |
protected $longitude; | |
/** | |
* @ORM\OneToMany(targetEntity="Ideato\OfferBundle\Entity\Offer", mappedBy="company") | |
**/ | |
private $offers; | |
/** | |
* @ORM\Column(name="created_at", type="datetime", nullable=true) | |
*/ | |
protected $created_at; | |
/** | |
* @ORM\Column(name="updated_at", type="datetime", nullable=true) | |
*/ | |
protected $updated_at; | |
public function __construct() | |
{ | |
$this->offers = new ArrayCollection(); | |
} | |
public function serialize(JsonSerializer $serializer) | |
{ | |
$path = $serializer->imgPath($this, 'picture'); | |
$thumb_path = $serializer->imgAliasPath($path, 'offer_homepage'); | |
return array( | |
'id' => $this->id, | |
'name' => $this->name, | |
'imgSrc' => $path, | |
'imgThumbSrc' => $thumb_path, | |
'lat' => $this->latitude, | |
'lng' => $this->longitude, | |
'permalink' => $serializer->entityPath($this, 'company'), | |
); | |
} | |
public function __toString() { return $this->getName(); } | |
public function getId() { return $this->id; } | |
public function setId($id) { $this->id = $id; } | |
public function getName() { return $this->name; } | |
public function setName($name) { $this->name = $name; } | |
public function getAddress() { return $this->address; } | |
public function setAddress($address) {$this->address = $address; } | |
public function getPhone() { return $this->address; } | |
public function setPhone($phone) { $this->phone = $phone; } | |
public function getWeb() { return $this->web; } | |
public function setWeb($web) { $this->web = $web; } | |
public function getLatitude() { return $this->latitude; } | |
public function setLatitude($latitude) { $this->latitude = $latitude; } | |
public function getLongitude() { return $this->longitude; } | |
public function setLongitude($longitude) { $this->longitude = $longitude; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment