Beispiel #1
0
 /**
  * @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;
 }
Beispiel #2
0
 /**
  * Updates Mandate name: if there is no name, one is generated.
  *
  * @param Mandate $mandate
  */
 public function updateName(Mandate $mandate)
 {
     if (false === empty($mandate->getName()) || true === empty($mandate->getStartAt())) {
         return;
     }
     if (null !== $mandate->getEndAt() && $mandate->getStartAt()->format('Y') !== $mandate->getEndAt()->format('Y')) {
         $name = sprintf('Mandate %s/%s', $mandate->getStartAt()->format('Y'), $mandate->getEndAt()->format('Y'));
     } else {
         $name = sprintf('Mandate %s %s', $mandate->getStartAt()->format('m'), $mandate->getStartAt()->format('Y'));
     }
     $mandate->setName($name);
 }