Skip to content

Instantly share code, notes, and snippets.

@doctrinebot
Created December 13, 2015 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doctrinebot/235b849e75bca10370e6 to your computer and use it in GitHub Desktop.
Save doctrinebot/235b849e75bca10370e6 to your computer and use it in GitHub Desktop.
Attachments to Doctrine Jira Issue DDC-1770 - https://github.com/doctrine/doctrine2/issues/2422
<?php
namespace ProFolio\Bundle\ProFolioBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* ProFolio\Bundle\ProFolioBundle\Entity\HistoryItem
*
* @ORM\Entity()
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="type", type="string")
* @ORM\DiscriminatorMap({"photo" = "PhotoHistoryItem", "comment" = "CommentHistoryItem"})
*/
class HistoryItem
{
/**
* @var integer $id
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var datetime $createdAt
*
* @ORM\Column(name="createdAt", type="datetime")
*/
protected $createdAt;
/**
* @var string $type
*/
protected $type;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set createdAt
*
* @param datetime $createdAt
*/
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
}
/**
* Get createdAt
*
* @return datetime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Get type
*
* @return string
*/
public function getType()
{
return $this->type;
}
}
<?php
namespace ProFolio\Bundle\ProFolioBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* ProFolio\Bundle\ProFolioBundle\Entity\CommentHistoryItem
*
* @ORM\Entity()
* @ORM\HasLifecycleCallbacks()
*/
class CommentHistoryItem extends HistoryItem
{
/**
* @var Comment $comment
*
* @ORM\OneToOne(targetEntity="Comment")
* @ORM\JoinColumn(name="comment_id", referencedColumnName="id")
*/
private $comment;
/**
* @return Comment
*/
public function getComment()
{
return $this->comment;
}
/**
* @param Comment $comment
*/
public function setComment(Comment $comment)
{
$this->comment = $comment;
}
/**
* @ORM\PrePersist()
*/
public function executePrePersist()
{
$this->setCreatedAt($this->comment->getCreatedAt());
}
}
<?php
namespace ProFolio\Bundle\ProFolioBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* ProFolio\Bundle\ProFolioBundle\Entity\PhotoHistoryItem
*
* @ORM\Entity()
* @ORM\HasLifecycleCallbacks()
*/
class PhotoHistoryItem extends HistoryItem
{
/**
* @var Photo $photo
*
* @ORM\OneToOne(targetEntity="Photo")
* @ORM\JoinColumn(name="photo_id", referencedColumnName="id")
*/
private $photo;
/**
* @return Photo
*/
public function getPhoto()
{
return $this->photo;
}
/**
*
* @param Photo $photo
*/
public function setPhoto(Photo $photo)
{
$this->photo = $photo;
}
/**
* @ORM\PrePersist()
*/
public function executePrePersist()
{
$this->setCreatedAt($this->photo->getCreatedAt());
}
}
<?php
namespace ProFolio\Bundle\ProFolioBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* ProFolio\Bundle\ProFolioBundle\Entity\Photo
*
* @ORM\Table()
* @ORM\Entity(repositoryClass="ProFolio\Bundle\ProFolioBundle\Entity\PhotoRepository")
* @ORM\HasLifecycleCallbacks()
*/
class Photo
{
/**
*
*/
public function __construct() {
$this->comments = new ArrayCollection();
}
/**
* @var integer $id
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var \DateTime $created_at
*
* @ORM\Column(name="createdAt", type="datetime")
*/
private $createdAt;
/**
* @var \DateTime $updated_at
*
* @ORM\Column(name="updatedAt", type="datetime", nullable="true")
*/
private $updatedAt;
/**
* @var string $filename
*
* @ORM\Column(name="filename", type="string", length=255)
*/
private $filename;
/**
* @var string $title
*
* @ORM\Column(name="title", type="string", length=255)
* @Assert\NotBlank
*/
private $title;
/**
* @var text $description
*
* @ORM\Column(name="description", type="text")
*/
private $description;
/**
* @var string $slug
*
* @ORM\Column(name="slug", type="string", length=255, unique="true")
* @Assert\NotBlank
*/
private $slug;
/**
* @var string exifCamera
*
* @ORM\Column(name="exifCamera", type="string", length="255", nullable="true")
*/
private $exifCamera;
/**
* @var string exifLens
*
* @ORM\Column(name="exifLens", type="string", length="255", nullable="true")
*/
private $exifLens;
/**
* @var date exifDateShot
*
* @ORM\Column(name="exifDateShot", type="datetime", nullable="true")
*/
private $exifDateShot;
/**
* @var string exifFocalLength
*
* @ORM\Column(name="exifFocalLength", type="string", length="64", nullable="true")
*/
private $exifFocalLength;
/**
* @var string exifShutterSpeed
*
* @ORM\Column(name="exifShutterSpeed", type="string", length="8", nullable="true")
*/
private $exifShutterSpeed;
/**
* @var double exifAperture
*
* @ORM\Column(name="exifAperture", type="decimal", nullable="true")
*/
private $exifAperture;
/**
* @var integer exifIso
*
* @ORM\Column(name="exifIso", type="integer", nullable="true")
*/
private $exifIso;
/**
* @var boolean exifFlash
*
* @ORM\Column(name="exifFlash", type="boolean", nullable="true")
*/
private $exifFlash;
/**
* @var string exifExposureProgram
*
* @ORM\Column(name="exifExposureProgram", type="string", length="32", nullable="true")
*/
private $exifExposureProgram;
/**
* @var integer exifWidth
*
* @ORM\Column(name="exifWidth", type="integer", nullable="true")
*/
private $exifWidth;
/**
* @var integer exifHeight
*
* @ORM\Column(name="exifHeight", type="integer", nullable="true")
*/
private $exifHeight;
/**
* @var ArrayCollection $comments
*
* @ORM\OneToMany(targetEntity="Comment", mappedBy="photo")
* @ORM\OrderBy({"createdAt" = "DESC"})
*/
private $comments;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set filename
*
* @param string $filename
*/
public function setFilename($filename)
{
$this->filename = $filename;
}
/**
* Get filename
*
* @return string
*/
public function getFilename()
{
return $this->filename;
}
/**
* Set title
*
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set description
*
* @param text $description
*/
public function setDescription($description)
{
$this->description = $description;
}
/**
* Get description
*
* @return text
*/
public function getDescription()
{
return $this->description;
}
/**
* Set exif tags
*
* @param ArrayCollection $exifTags
*/
public function setExifTags($exifTags)
{
$this->exifTags = $exifTags;
}
/**
* Get exif tags
*
* @return ArrayCollection
*/
public function getExifTags()
{
return $this->exifTags;
}
/**
* Set slug
*
* @param string $slug
*/
public function setSlug($slug)
{
$this->slug = $slug;
}
/**
* Get slug
*
* @return string
*/
public function getSlug()
{
return $this->slug;
}
/**
* Set exifCamera
*
* @param string $exifCamera
*/
public function setExifCamera($exifCamera)
{
$this->exifCamera = $exifCamera;
}
/**
* Get exifCamera
*
* @return string
*/
public function getExifCamera()
{
return $this->exifCamera;
}
/**
* Set exifLens
*
* @param string $exifLens
*/
public function setExifLens($exifLens)
{
$this->exifLens = $exifLens;
}
/**
* Get exifLens
*
* @return string
*/
public function getExifLens()
{
return $this->exifLens;
}
/**
* Set exifDateShot
*
* @param datetime $exifDateShot
*/
public function setExifDateShot($exifDateShot)
{
$this->exifDateShot = $exifDateShot;
}
/**
* Get exifDateShot
*
* @return datetime
*/
public function getExifDateShot()
{
return $this->exifDateShot;
}
/**
* Set exifFocalLength
*
* @param string $exifFocalLength
*/
public function setExifFocalLength($exifFocalLength)
{
$this->exifFocalLength = $exifFocalLength;
}
/**
* Get exifFocalLength
*
* @return string
*/
public function getExifFocalLength()
{
return $this->exifFocalLength;
}
/**
* Set exifShutterSpeed
*
* @param string $exifShutterSpeed
*/
public function setExifShutterSpeed($exifShutterSpeed)
{
$this->exifShutterSpeed = $exifShutterSpeed;
}
/**
* Get exifShutterSpeed
*
* @return string
*/
public function getExifShutterSpeed()
{
return $this->exifShutterSpeed;
}
/**
* Set exifAperture
*
* @param decimal $exifAperture
*/
public function setExifAperture($exifAperture)
{
$this->exifAperture = $exifAperture;
}
/**
* Get exifAperture
*
* @return decimal
*/
public function getExifAperture()
{
return $this->exifAperture;
}
/**
* Set exifIso
*
* @param integer $exifIso
*/
public function setExifIso($exifIso)
{
$this->exifIso = $exifIso;
}
/**
* Get exifIso
*
* @return integer
*/
public function getExifIso()
{
return $this->exifIso;
}
/**
* Set exifFlash
*
* @param boolean $exifFlash
*/
public function setExifFlash($exifFlash)
{
$this->exifFlash = $exifFlash;
}
/**
* Get exifFlash
*
* @return boolean
*/
public function getExifFlash()
{
return $this->exifFlash;
}
/**
* Set exifExposureProgram
*
* @param string $exifExposureProgram
*/
public function setExifExposureProgram($exifExposureProgram)
{
$this->exifExposureProgram = $exifExposureProgram;
}
/**
* Get exifExposureProgram
*
* @return string
*/
public function getExifExposureProgram()
{
return $this->exifExposureProgram;
}
/**
* Set exifWidth
*
* @param integer $exifWidth
*/
public function setExifWidth($exifWidth)
{
$this->exifWidth = $exifWidth;
}
/**
* Get exifWidth
*
* @return integer
*/
public function getExifWidth()
{
return $this->exifWidth;
}
/**
* Set exifHeight
*
* @param integer $exifHeight
*/
public function setExifHeight($exifHeight)
{
$this->exifHeight = $exifHeight;
}
/**
* Get exifHeight
*
* @return integer
*/
public function getExifHeight()
{
return $this->exifHeight;
}
/**
* Set created_at
*
* @param \DateTime $createdAt
*/
public function setCreatedAt(\DateTime $createdAt)
{
$this->created_at = $createdAt;
}
/**
* Get created_at
*
* @return \DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set updated_at
*
* @param \DateTime $updatedAt
*/
public function setUpdatedAt(\DateTime $updatedAt)
{
$this->updatedAt = $updatedAt;
}
/**
* Get updated_at
*
* @return \DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* Set comments
*
* @param ArrayCollection $comments
*/
public function setComments(ArrayCollection $comments)
{
$this->comments = $comments;
}
/**
* Get comments
*
* @return \Doctrine\Common\Collections\ArrayCollection
*/
public function getComments()
{
return $this->comments;
}
/**
* @ORM\PrePersist()
*/
public function executePrePersist()
{
$this->createdAt = new \DateTime();
}
/**
* @ORM\PreUpdate()
*/
public function executePreUpdate()
{
$this->updatedAt = new \DateTime();
}
}
<?php
namespace ProFolio\Bundle\ProFolioBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* ProFolio\Bundle\ProFolioBundle\Entity\Comment
*
* @ORM\Entity(repositoryClass="ProFolio\Bundle\ProFolioBundle\Entity\CommentRepository")
* @ORM\Table()
* @ORM\HasLifecycleCallbacks()
*/
class Comment
{
/**
* @var integer $id
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var Photo $photo
*
* @ORM\ManyToOne(targetEntity="Photo", inversedBy="comments")
*
* @Assert\NotNull
*/
private $photo;
/**
* @var string $author
*
* @ORM\Column(name="author", type="string", length="255")
*
* @Assert\NotNull
* @Assert\NotBlank
*/
private $author;
/**
* @var string $email
*
* @ORM\Column(name="email", type="string", length="255", nullable="false")
*
* @Assert\Email
* @Assert\NotNull
* @Assert\NotBlank
*/
private $email;
/**
* @var string $url
*
* @ORM\Column(name="url", type="string", length="255", nullable="true")
*
* @Assert\Url
*/
private $url;
/**
* @var string $content
*
* @ORM\Column(name="content", type="text")
*
* @Assert\NotBlank
*/
private $content;
/**
* @var boolean $spam
*
* @ORM\Column(name="spam", type="boolean", nullable="true")
*/
private $spam;
/**
* @var datetime $created_at
*
* @ORM\Column(name="createdAt", type="datetime")
*/
private $createdAt;
/**
* @var datetime $updatedAt
*
* @ORM\Column(name="updatedAt", type="datetime", nullable="true")
*/
private $updatedAt;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set author
*
* @param string $author
*/
public function setAuthor($author)
{
$this->author = $author;
}
/**
* Get author
*
* @return string
*/
public function getAuthor()
{
return $this->author;
}
/**
* Set email
*
* @param string $email
*/
public function setEmail($email)
{
$this->email = $email;
}
/**
* Get email
*
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* Set url
*
* @param string $url
*/
public function setUrl($url)
{
$this->url = $url;
}
/**
* Get url
*
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* Set content
*
* @param text $content
*/
public function setContent($content)
{
$this->content = $content;
}
/**
* Get content
*
* @return text
*/
public function getContent()
{
return $this->content;
}
/**
* Set createdAt
*
* @param datetime $createdAt
*/
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
}
/**
* Get createdAt
*
* @return datetime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set photo
*
* @param ProFolio\Bundle\ProFolioBundle\Entity\Photo $photo
*/
public function setPhoto(\ProFolio\Bundle\ProFolioBundle\Entity\Photo $photo)
{
$this->photo = $photo;
}
/**
* Get photo
*
* @return ProFolio\Bundle\ProFolioBundle\Entity\Photo
*/
public function getPhoto()
{
return $this->photo;
}
/**
*
* @return boolean
*/
public function isSpam()
{
return $this->spam;
}
/**
*
* @param unknown_type $spam
*/
public function setSpam($spam)
{
$this->spam = $spam;
}
/**
* Set createdAt
*
* @param datetime $createdAt
*/
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = $updatedAt;
}
/**
* Get createdAt
*
* @return datetime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* @ORM\PrePersist()
*/
public function executePrePersist()
{
$this->createdAt = new \DateTime();
}
/**
* @ORM\PreUpdate()
*/
public function executePreUpdate()
{
$this->updatedAt = new \DateTime();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment