/** * @param Mandate|null $mandate * * @return $this */ public function setMandate(Mandate $mandate = null) { // Handle bidirectional relationship // Check for the other side first if (null === $mandate && null !== $this->mandate && true === $this->mandate->getJobs()->contains($this)) { // Mandate was set and is being reset // Since it's a bidirectional relationship, unset the other relation from the other side first $this->mandate->removeJob($this); } elseif (null !== $mandate && false === $mandate->getJobs()->contains($this)) { $mandate->addJob($this); } $this->mandate = $mandate; return $this; }
/** * {@inheritdoc} * * @param Mandate $entity */ public function remove($entity) { foreach ($entity->getJobs() as $job) { $job->setMandate(null); } }