public function setAnimal($id)
 {
     $animal = $this->animalRepository->findByIdentifier($id);
     foreach ($animal->getTreatments() as $tr) {
         foreach ($tr->getTherapies() as $th) {
             $this->therapies[$this->persistenceManager->getIdentifierByObject($th)] = true;
         }
     }
 }
 /**
  * @param mixed $value The value that should be validated
  * @return void
  * @throws \TYPO3\Flow\Validation\Exception\InvalidSubjectException
  */
 protected function isValid($value)
 {
     $animal = null;
     if ($this->tag != $value->getRFID()) {
         $animal = $this->animalRepository->findOneByRFID($this->tag);
     }
     if ($animal == null) {
         if ($this->tag != $value->getEarTag()) {
             $animal = $this->animalRepository->findOneByEarTag($this->tag);
         }
     }
     if ($animal != null) {
         $this->addError('The animal with this RFID/Ear tag already exists.', 9996);
     }
 }
Esempio n. 3
0
 private function getAnimal($entity)
 {
     $animal = null;
     if (method_exists($entity, 'getAnimal')) {
         $animal = $entity->getAnimal();
     } elseif (method_exists($entity, 'getOldAnimal')) {
         $animal = $entity->getOldAnimal();
     } elseif ($entity instanceof \DLigo\Animaltool\Domain\Model\Owner) {
         $animal = $this->animalRepository->findByOwner($entity)->getFirst();
         if (empty($animal)) {
             $id = $this->persistenceManager->getIdentifierByObject($entity);
             if (isset($this->owners[$id])) {
                 $animal = $this->owners[$id];
             }
         }
     } elseif ($entity instanceof \TYPO3\Flow\Resource\Resource) {
         $animal = $this->animalRepository->findByPhoto($entity)->getFirst();
         if (empty($animal)) {
             $id = $this->persistenceManager->getIdentifierByObject($entity);
             if (isset($this->photos[$id])) {
                 $animal = $this->photos[$id];
             }
         }
     } elseif ($entity instanceof \TYPO3\Flow\Resource\ResourcePointer) {
         $animal = $this->animalRepository->findByPhotoPointer($entity)->getFirst();
         if (empty($animal)) {
             $id = $this->persistenceManager->getIdentifierByObject($entity);
             if (isset($this->photospointer[$id])) {
                 $animal = $this->photospointer[$id];
             }
         }
     } elseif ($entity instanceof \DLigo\Animaltool\Domain\Model\Animal) {
         $animal = $entity;
     }
     if (!empty($animal)) {
         return $animal;
     }
     return '';
 }
Esempio n. 4
0
 public function releaseAction(\DLigo\Animaltool\Domain\Model\Animal $animal)
 {
     $animal->setStayStatus(\DLigo\Animaltool\Domain\Model\Animal::RELEASED);
     $this->animalRepository->update($animal);
     $this->response->setStatus(204);
 }