/** * @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; }
public function publishers() { $kind = $this->kindRepo->get('publisher'); $parties = $this->partyRepo->partiesOfKind($kind); return $this->jsonResponse($parties); }