private function addPhoto(Form $form, $values) { if ($values->photoId == "0") { $values->filepath = $this->storePhotos($values); $photo = $this->formValuesToEntity($form, $values); $newPhoto = $this->photoFacade->save($photo); $form->getPresenter()->getTemplate()->photoMessage = "photoAdded"; $form->setValues([], TRUE); $photos = new PhotoCollection(); $photos->addItem($newPhoto); $form->getPresenter()->getTemplate()->photos = $photos; $form->getPresenter()->redrawControl("articleWrapper"); $form->getPresenter()->redrawControl("photoResult"); } else { $photo = $this->formValuesToEntity($form, $values); $this->photoFacade->save($photo); $form->getPresenter()->getTemplate()->photoMessage = "photoEdited"; $editedPhoto = $this->photoFacade->findOneById($photo->id); $form->getPresenter()->getTemplate()->editPhoto = $editedPhoto; $form->getPresenter()->getTemplate()->photoPreview = $editedPhoto; $form->getPresenter()->redrawControl("articleWrapper"); $form->getPresenter()->redrawControl("photoPreview"); } $form->getPresenter()->redrawControl("addPhotoForm"); }
private function toCollection(DbEntries $users) { return PhotoCollection::loadFromDb($users); }