Created
January 15, 2013 00:45
-
-
Save oopsFrogs/4534971 to your computer and use it in GitHub Desktop.
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 MyVendor\ImageBundle\Entity; | |
| use Doctrine\ORM\Mapping as ORM, | |
| Vich\UploaderBundle\Mapping\Annotation as Vich; | |
| /** | |
| * @ORM\Entity | |
| * @Vich\Uploadable | |
| * @ORM\InheritanceType("JOINED") | |
| * @ORM\DiscriminatorColumn(name="discr", type="string") | |
| * @ORM\DiscriminatorMap({ | |
| * "image" = "Image", | |
| * "logo" = "LogoImage", | |
| * "regular" = "RegularImage" | |
| * }) | |
| * | |
| * @author travisyang | |
| */ | |
| class Image | |
| { | |
| /** | |
| * @ORM\Id | |
| * @ORM\Column(type="bigint") | |
| * @ORM\GeneratedValue(strategy="AUTO") | |
| * @var bigint | |
| */ | |
| protected $id; | |
| /** | |
| * @ORM\Column(type="datetime") | |
| * | |
| * @var datetime $uploadedAt | |
| */ | |
| protected $uploadedAt; | |
| /** | |
| * @ORM\ManyToOne(targetEntity="\MyVendor\UserBundle\Entity\User", inversedBy="images") | |
| * @ORM\JoinColumn(name="user_id", referencedColumnName="id") | |
| * | |
| * @var User $user | |
| */ | |
| protected $user; | |
| public function getId() | |
| { | |
| return $this->id; | |
| } | |
| public function getUploadedAt() | |
| { | |
| return $this->uploadedAt; | |
| } | |
| public function setUser(\MyVendor\UserBundle\Entity\User $user) | |
| { | |
| $this->user = $user; | |
| $user->addImage($this); | |
| } | |
| public function getUser() | |
| { | |
| return $this->user; | |
| } | |
| public function __construct() | |
| { | |
| $this->uploadedAt = new \DateTime("now"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment