Esempio n. 1
0
 /**
  * @param $data
  * @param $group
  * @return mixed
  */
 private function setKind($data, $group)
 {
     if (isset($data['kind']) && isset($data['kind']['name'])) {
         $kind_name = $data['kind']['name'];
         $kind = $this->kindRepo->get($kind_name);
         if ($kind) {
             //TODO throw error when kind is not found
             $group->setKind($kind);
             return $data;
         }
         return $data;
     }
     return $data;
 }
Esempio n. 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;
 }
Esempio n. 3
0
 public function publishers()
 {
     $kind = $this->kindRepo->get('publisher');
     $parties = $this->partyRepo->partiesOfKind($kind);
     return $this->jsonResponse($parties);
 }