@@ -33,16 +33,18 @@ class Webhook
3333 #[ORM \Column(type: 'json ' , nullable: true )]
3434 private array $ headers = [];
3535
36- #[ORM \ManyToOne(targetEntity: Repository::class)]
37- private ?Repository $ repository = null ;
36+ /** @phpstan-var Collection<int, Repository> */
37+ #[ORM \ManyToMany(targetEntity: Repository::class)]
38+ private Collection $ repositories ;
3839
3940 /** @phpstan-var Collection<int, WebhookActivity> */
4041 #[ORM \OneToMany(mappedBy: 'webhook ' , targetEntity: WebhookActivity::class, cascade: ['persist ' , 'remove ' ], orphanRemoval: false )]
4142 private Collection $ activities ;
4243
4344 public function __construct ()
4445 {
45- $ this ->activities = new ArrayCollection ();
46+ $ this ->repositories = new ArrayCollection ();
47+ $ this ->activities = new ArrayCollection ();
4648 }
4749
4850 public function setId (int $ id ): self
@@ -123,14 +125,37 @@ public function setHeaders(array $headers): self
123125 return $ this ;
124126 }
125127
126- public function getRepository ( ): ? Repository
128+ public function setHeader ( string $ key , ? string $ value ): self
127129 {
128- return $ this ->repository ;
130+ if ($ value === null ) {
131+ unset($ this ->headers [$ key ]);
132+ } else {
133+ $ this ->headers [$ key ] = $ value ;
134+ }
135+
136+ return $ this ;
137+ }
138+
139+ /**
140+ * @return Collection<int, Repository>
141+ */
142+ public function getRepositories (): Collection
143+ {
144+ return $ this ->repositories ;
145+ }
146+
147+ public function addRepository (Repository $ repository ): self
148+ {
149+ if (!$ this ->repositories ->contains ($ repository )) {
150+ $ this ->repositories ->add ($ repository );
151+ }
152+
153+ return $ this ;
129154 }
130155
131- public function setRepository (? Repository $ repository ): self
156+ public function removeRepository ( Repository $ repository ): self
132157 {
133- $ this ->repository = $ repository ;
158+ $ this ->repositories -> removeElement ( $ repository) ;
134159
135160 return $ this ;
136161 }
0 commit comments