/** * @param \DLigo\Animaltool\Domain\Model\Animal $newAnimal * @param \DLigo\Animaltool\Domain\Model\Owner $newOwner * @param array<\DLigo\Animaltool\Domain\Model\Bread> $bread * @param string $tag * @Flow\Validate (argumentName="$newAnimal.photo", type="NotEmpty") * @Flow\Validate (argumentName="$newAnimal.gender", type="NotEmpty") * @return void */ public function createAction(Animal $newAnimal, \DLigo\Animaltool\Domain\Model\Owner $newOwner, $bread, $tag = '') { $oldAnimal = null; $duplicate = false; $dummyAction = new \DLigo\Animaltool\Domain\Model\Action(); $dummyAction->setLat(0); $dummyAction->setLng(0); $dummyAction->setAnimal($newAnimal); $dummyAction->setDate(new \DateTime('now')); $user = $this->session->getUser(); $boxid = $user->getTeamID() . '-' . ($user->getLastBoxID() + 1); $dummyAction->setBoxID($boxid); $dummyAction->setTeam($user); $location = $this->session->getLocation(); if ($location == null) { $location = $newAnimal->getLocation(); } $dummyAction->setLocation($location); $newAnimal->setLocation($location); $speciesid = $this->persistenceManager->getIdentifierByObject($newAnimal->getSpecies()); $breadid = $bread[$speciesid]; $newAnimal->setBread($breadid); $newAnimal->setStayStatus(Animal::CATCHED); $newAnimal->setTherapyStatus(Animal::WAIT); $this->actionRepository->add($dummyAction); $newAnimal->setOwner($newOwner); if (!empty($tag)) { $oldAnimal = $this->animalRepository->findByRFID($tag)->getFirst(); if ($oldAnimal) { $tag = "_DUMMY_" . $tag . "_" . time(); $duplicate = true; $newAnimal->setIsDummy(true); } $newAnimal->setRFID($tag); } $this->ownerRepository->add($newOwner); $this->animalRepository->add($newAnimal); $this->addFlashMessage('Created a new animal.', '', \TYPO3\Flow\Error\Message::SEVERITY_OK, array(), 'flash.animal.new'); if ($duplicate) { $this->redirect('duplicate', null, null, array('animal' => $newAnimal, 'oldAnimal' => $oldAnimal)); } $this->redirect('treatment', null, null, array('animal' => $newAnimal)); }