Skip to content
Snippets Groups Projects
Select Git revision
  • 424d107997852c39c5fd152aae03741fabb5b806
  • main default
  • 35-cgu
  • 34-peertube-support
  • 27-add-autoplay-to-iframe
  • 33-bug-on-youtube-embed-urls
  • RC-Rekall-v1.1-fix_lpo
  • tuleap-140-go-back-to-my-capsules-page-when-i-m-on-capsule-preview-page
  • RC-Rekall-v1.2-fix10
  • RC-Rekall-v1.2-fix9
  • RC-Rekall-v1.2-fix8
  • RC-Rekall-v1.2-fix7
  • RC-Rekall-v1.2-fix6
  • RC-Rekall-v1.2-fix5
  • RC-Rekall-v1.2-fix4
  • RC-Rekall-v1.2-fix3
  • RC-Rekall-v1.2-fix2
  • RC-Rekall-v1.2-fix1
  • RC-Rekall-v1.1-fix-3
  • RC-Rekall-v1.1-fix-2
  • RC-Rekall-v1.1-fix-1
  • RC-Rekall-v1.1-delivered
  • preprod20220209-1535
23 results

StringHelper.php

Blame
  • Group.php 2.39 KiB
    <?php
    
    namespace App\Entity;
    
    use App\Repository\GroupRepository;
    use Doctrine\Common\Collections\ArrayCollection;
    use Doctrine\Common\Collections\Collection;
    use Doctrine\ORM\Mapping as ORM;
    use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
    
    #[ORM\Entity(repositoryClass:GroupRepository::class)]
    #[ORM\Table(name:'`group`')]
    #[ORM\UniqueConstraint(columns: ['name', 'author'])]
    #[UniqueEntity(fields: ['name', 'author'], message: 'group.name.unique', errorPath: 'name')]
    class Group
    {
        public static int $GROUP_ALL_ID = -1;
    
        #[ORM\Id]
        #[ORM\GeneratedValue]
        #[ORM\Column(type:'integer')]
        private int $id;
    
        #[ORM\Column(type:'string', length:255)]
        private string $name;
    
        #[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'groups')]
        #[ORM\JoinColumn(name: 'author', referencedColumnName: 'id', nullable: false)]
        protected User $author;
    
        /**
         * @var Collection<Capsule>
         */
        #[ORM\ManyToMany(targetEntity:Capsule::class, inversedBy:'groups')]
        private Collection $capsules;
    
        public function __construct()
        {
            $this->capsules = new ArrayCollection();
        }
    
        public function getId(): int
        {
            return $this->id;
        }
    
        public function setId(int $id): void
        {
            $this->id = $id;
        }
    
        public function getName(): string
        {
            return $this->name;
        }
    
        public function setName(string $name): self
        {
            $this->name = $name;
            return $this;
        }
    
        public function getAuthor(): User
        {
            return $this->author;
        }
    
        public function setAuthor(User $author): self
        {
            $this->author = $author;
            return $this;
        }
    
        /**
         * @return Collection<Capsule>
         */
        public function getCapsules(): Collection
        {
            return $this->capsules;
        }
    
        public function addCapsule(Capsule $capsule): self
        {
            if (!$this->capsules->contains($capsule)) {
                $this->capsules[] = $capsule;
                $capsule->addGroup($this);
            }
    
            return $this;
        }
    
        /**
         * @param array<Capsule> $capsules
         */
        public function addCapsules(array $capsules): self
        {
            foreach ($capsules as $capsule) {
                $this->addCapsule($capsule);
            }
    
            return $this;
        }
    
        public function removeCapsule(Capsule $capsule): self
        {
            $this->capsules->removeElement($capsule);
            return $this;
        }
    }