X-Git-Url: https://git.rapsys.eu/airbundle/blobdiff_plain/42d2646c377a92fd92d37e09ef6b733fa9b50946..2884b5c8b4514b0e1c0dd0449db2af5be32382b6:/Entity/Snippet.php?ds=sidebyside diff --git a/Entity/Snippet.php b/Entity/Snippet.php index 2aa9d3b..dea8897 100644 --- a/Entity/Snippet.php +++ b/Entity/Snippet.php @@ -1,55 +1,101 @@ - + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace Rapsys\AirBundle\Entity; -use Rapsys\AirBundle\Entity\Location; -use Rapsys\AirBundle\Entity\User; +use Doctrine\ORM\Event\PreUpdateEventArgs; /** * Snippet */ class Snippet { + /** + * Primary key + */ + private ?int $id = null; + + /** + * @var string + */ + private ?string $description = null; + + /** + * @var string + */ + private ?string $class = null; + + /** + * @var string + */ + private ?string $short = null; + /** * @var integer */ - private $id; + private ?int $rate = null; + + /** + * @var bool + */ + private ?bool $hat = null; /** * @var string */ - protected $locale; + private ?string $contact = null; /** - * @var text + * @var string */ - protected $description; + private ?string $donate = null; /** - * @var \DateTime + * @var string + */ + private ?string $link = null; + + /** + * @var string */ - protected $created; + private ?string $profile = null; /** - * @var \DateTime + * Create datetime */ - protected $updated; + private \DateTime $created; /** - * @var \Rapsys\UserBundle\Entity\Location + * Update datetime */ - protected $location; + private \DateTime $updated; /** - * @var \Rapsys\UserBundle\Entity\User + * Constructor + * + * @param string $locale The locale + * @param Location $location The location instance + * @param User $user The user instance */ - protected $user; + public function __construct(private string $locale, private Location $location, private User $user) { + //Set defaults + $this->created = new \DateTime('now'); + $this->updated = new \DateTime('now'); + } /** * Get id * * @return integer */ - public function getId() { + public function getId(): ?int { return $this->id; } @@ -60,7 +106,7 @@ class Snippet { * * @return Snippet */ - public function setLocale($locale) { + public function setLocale(string $locale): Snippet { $this->locale = $locale; return $this; @@ -71,7 +117,7 @@ class Snippet { * * @return string */ - public function getLocale() { + public function getLocale(): string { return $this->locale; } @@ -82,7 +128,7 @@ class Snippet { * * @return Snippet */ - public function setDescription($description) { + public function setDescription(?string $description): Snippet { $this->description = $description; return $this; @@ -93,18 +139,193 @@ class Snippet { * * @return string */ - public function getDescription() { + public function getDescription(): ?string { return $this->description; } + /** + * Set class + * + * @param string $class + * + * @return Snippet + */ + public function setClass(?string $class): Snippet { + $this->class = $class; + + return $this; + } + + /** + * Get class + * + * @return string + */ + public function getClass(): ?string { + return $this->class; + } + + /** + * Set short + * + * @param string $short + * + * @return Snippet + */ + public function setShort(?string $short): Snippet { + $this->short = $short; + + return $this; + } + + /** + * Get short + * + * @return string + */ + public function getShort(): ?string { + return $this->short; + } + + /** + * Set rate + * + * @param int $rate + * + * @return Snippet + */ + public function setRate(?int $rate): Snippet { + $this->rate = $rate; + + return $this; + } + + /** + * Get rate + * + * @return int + */ + public function getRate(): ?int { + return $this->rate; + } + + /** + * Set hat + * + * @param bool $hat + * + * @return User + */ + public function setHat(?bool $hat): Snippet { + $this->hat = $hat; + + return $this; + } + + /** + * Get hat + * + * @return bool + */ + public function getHat(): ?bool { + return $this->hat; + } + /** + * Set contact + * + * @param string $contact + * + * @return Snippet + */ + public function setContact(?string $contact): Snippet { + $this->contact = $contact; + + return $this; + } + + /** + * Get contact + * + * @return string + */ + public function getContact(): ?string { + return $this->contact; + } + + /** + * Set donate + * + * @param string $donate + * + * @return Snippet + */ + public function setDonate(?string $donate): Snippet { + $this->donate = $donate; + + return $this; + } + + /** + * Get donate + * + * @return string + */ + public function getDonate(): ?string { + return $this->donate; + } + + /** + * Set link + * + * @param string $link + * + * @return Snippet + */ + public function setLink(?string $link): Snippet { + $this->link = $link; + + return $this; + } + + /** + * Get link + * + * @return string + */ + public function getLink(): ?string { + return $this->link; + } + + /** + * Set profile + * + * @param string $profile + * + * @return Snippet + */ + public function setProfile(?string $profile): Snippet { + $this->profile = $profile; + + return $this; + } + + /** + * Get profile + * + * @return string + */ + public function getProfile(): ?string { + return $this->profile; + } + /** * Set created * * @param \DateTime $created * - * @return User + * @return Snippet */ - public function setCreated($created) { + public function setCreated(\DateTime $created): Snippet { $this->created = $created; return $this; @@ -115,7 +336,7 @@ class Snippet { * * @return \DateTime */ - public function getCreated() { + public function getCreated(): \DateTime { return $this->created; } @@ -124,9 +345,9 @@ class Snippet { * * @param \DateTime $updated * - * @return User + * @return Snippet */ - public function setUpdated($updated) { + public function setUpdated(\DateTime $updated): Snippet { $this->updated = $updated; return $this; @@ -137,14 +358,18 @@ class Snippet { * * @return \DateTime */ - public function getUpdated() { + public function getUpdated(): \DateTime { return $this->updated; } /** * Set location + * + * @param Location $location + * + * @return Snippet */ - public function setLocation(Location $location) { + public function setLocation(Location $location): Snippet { $this->location = $location; return $this; @@ -152,15 +377,21 @@ class Snippet { /** * Get location + * + * @return Location */ - public function getLocation() { + public function getLocation(): Location { return $this->location; } /** * Set user + * + * @param User $user + * + * @return Snippet */ - public function setUser(User $user) { + public function setUser(User $user): Snippet { $this->user = $user; return $this; @@ -168,8 +399,21 @@ class Snippet { /** * Get user + * + * @return User */ - public function getUser() { + public function getUser(): User { return $this->user; } + + /** + * {@inheritdoc} + */ + public function preUpdate(PreUpdateEventArgs $eventArgs) { + //Check that we have an snippet instance + if (($snippet = $eventArgs->getObject()) instanceof Snippet) { + //Set updated value + $snippet->setUpdated(new \DateTime('now')); + } + } }