Example #1
0
 public function __construct($name)
 {
     parent::__construct($name);
 }
Example #2
0
 /**
  * @param $publisher
  * @return Party
  * @throws NotFoundException
  * @throws UnprocessableEntityException
  */
 private function findOrCreatePublisher($publisher)
 {
     if (isset($publisher['id'])) {
         $pub = $this->partyRepo->partyOfId($publisher['id']);
         if (!$pub) {
             throw new NotFoundException('publisher_not_found', $publisher['id']);
         }
     } else {
         $name = new Name($publisher['last_name']);
         $pubKind = $this->kindRepo->get('publisher');
         $pub = $this->partyRepo->partyOfNameAndKind($name, $pubKind);
         if (!$pub) {
             $pub = new Party($name);
             $pub->setKind($pubKind);
             $this->partyRepo->add($pub);
         }
     }
     return $pub;
 }
 /**
  * @param Organization $organization
  * @param Party $publisher
  * @return ArrayCollection
  */
 public function booksOfPublisher(Organization $organization, Party $publisher)
 {
     $qb = $this->em->createQueryBuilder();
     $query = $qb->select('b')->from($this->bookClass, 'b')->join('b.publishers', 'p')->where($qb->expr()->eq('p.id', '?1'))->setParameter(1, $publisher->id());
     return $query->getQuery()->getResult();
 }
 /**
  * Destroys a relation that was alive before a given date
  *
  * @param Party $context
  * @param Party $reference
  * @param DateTime $date
  * @param Kind $kind
  */
 public function destroyBefore(Party $context, Party $reference, DateTime $date, Kind $kind)
 {
     $qb = $this->em->createQueryBuilder();
     $qb->select('pr')->update($this->class, 'pr')->set('pr.end', '?5')->where($qb->expr()->eq('pr.context', '?1'), $qb->expr()->eq('pr.reference', '?2'), $qb->expr()->lt('pr.start', '?3'), $qb->expr()->isNull('pr.end'), $qb->expr()->eq('pr.kind', '?4'))->setParameter(1, $context->id())->setParameter(2, $reference->id())->setParameter(3, $date)->setParameter(4, $kind)->setParameter(5, new DateTime());
     $qb->getQuery()->execute();
 }