Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * File CommonEntity
- * Entity ancestor
- *
- * - Identified
- * - Timestamped
- *
- * @ORM\MappedSuperclass
- * @ORM\HasLifecycleCallbacks
- *
- * Petr Blažíček 2014
- */
- abstract class CommonEntity extends SimpleEntity
- {
- /**
- * @ORM\Column(type="datetimetz")
- * @var DateTime
- */
- protected $created;
- /**
- * @ORM\Column(type="datetimetz")
- * @var DateTime
- */
- protected $updated;
- /**
- * @return DateTime
- */
- public function getCreated()
- {
- return $this->created;
- }
- /**
- * @ORM\PrePersist
- */
- public function prePersist()
- {
- $this->updated = $this->created = new DateTime();
- }
- /**
- * @return DateTime
- */
- public function getUpdated()
- {
- return $this->updated;
- }
- /**
- * @ORM\PreUpdate
- */
- public function preUpdate()
- {
- $this->updated = new DateTime();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement