123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- <?php
-
- namespace Muzich\CoreBundle\Entity;
-
- use Doctrine\ORM\Mapping as ORM;
-
- /**
- * Cette classe représente la relation porteuse entre User et Tag,
- * en tant que Tags favoris de l'utilisateur.
- *
- * @ORM\Entity
- * @ORM\Table(name="users_tags_favorites")
- * @ORM\HasLifecycleCallbacks
- */
- class UsersTagsFavorites
- {
-
- /**
- * @ORM\Id
- * @ORM\Column(type="integer")
- * @ORM\GeneratedValue(strategy="AUTO")
- * @var type int
- */
- protected $id;
-
- /**
- * Cet attribut contient l'objet User lié
- *
- * @ORM\ManyToOne(targetEntity="User", inversedBy="tags_favorites")
- * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
- */
- protected $user;
-
- /**
- * Cet attribut contient l'objet Tag lié
- *
- * @ORM\ManyToOne(targetEntity="Tag", inversedBy="users_favorites")
- * @ORM\JoinColumn(name="tag_id", referencedColumnName="id", onDelete="CASCADE")
- */
- protected $tag;
-
- /**
- * L'attribut position permet de connaitre l'ordre de préfèrence de
- * l'utilisateur.
- *
- * @ORM\Column(type="integer", nullable=true)
- * @var type int
- */
- protected $position;
-
-
- /**
- * Set position
- *
- * @param integer $position
- */
- public function setPosition($position)
- {
- $this->position = $position;
- }
-
- /**
- * Get position
- *
- * @return integer
- */
- public function getPosition()
- {
- return $this->position;
- }
-
-
- /**
- * Get id
- *
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
-
- /**
- * Set user
- *
- * @param User $user
- */
- public function setUser(User $user)
- {
- $this->user = $user;
- }
-
- /**
- * Get user
- *
- * @return User
- */
- public function getUser()
- {
- return $this->user;
- }
-
- /**
- * Set tag
- *
- * @param Tag $tag
- */
- public function setTag(Tag $tag)
- {
- $this->tag = $tag;
- }
-
- /**
- * Get tag
- *
- * @return Tag
- */
- public function getTag()
- {
- return $this->tag;
- }
-
- /**
- * @ORM\PrePersist
- */
- public function prePersist()
- {
- $this->getUser()->addTagFavoriteQuick($this->getTag());
- }
-
- /**
- * @ORM\PreRemove
- */
- public function preRemove()
- {
- $this->getUser()->removeTagFavoriteQuick($this->getTag());
- }
-
- }
|