/** * Updating the image. Inspired by FileController::updateFileAction(). * * @param DiaporamaImage $file Diaporama Image ID. * @param string $eventName the event type. * * @return DiaporamaImage */ protected function updateImageFile(DiaporamaImage $file) { $fileUpdateForm = $this->createForm($file->getUpdateFormId()); try { if (null === $file) { throw new \InvalidArgumentException(sprintf('%d image id does not exist', $file->getId())); } $event = new FileCreateOrUpdateEvent(null); $event->setModel($file); $event->setOldModel($file); $fileForm = $this->getRequest()->files->get($fileUpdateForm->getName()); if (isset($fileForm['file'])) { $event->setUploadedFile($fileForm['file']); } $this->dispatch(TheliaEvents::IMAGE_SAVE, $event); $fileUpdated = $event->getModel(); $this->adminLogAppend(AdminResources::MODULE, AccessManager::UPDATE, sprintf('Image with Ref %s (ID %d) modified', $fileUpdated->getTitle(), $fileUpdated->getId())); if ($this->getRequest()->get('save_mode') == 'close') { return $this->generateRedirect(URL::getInstance()->absoluteUrl($file->getRedirectionUrl(), ['current_tab' => 'images'])); } else { return $this->generateSuccessRedirect($fileUpdateForm); } } catch (PropelException $e) { $message = $e->getMessage(); } catch (\Exception $e) { $message = sprintf('Sorry, an error occurred: %s', $e->getMessage() . ' ' . $e->getFile()); } if (isset($message)) { Tlog::getInstance()->error(sprintf('Error during image editing : %s.', $message)); $fileUpdateForm->setErrorMessage($message); $this->getParserContext()->addForm($fileUpdateForm)->setGeneralError($message); } return $file; }
/** * Filter the query by a related \Diaporamas\Model\DiaporamaImage object * * @param \Diaporamas\Model\DiaporamaImage|ObjectCollection $diaporamaImage The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildDiaporamaImageI18nQuery The current query, for fluid interface */ public function filterByDiaporamaImage($diaporamaImage, $comparison = null) { if ($diaporamaImage instanceof \Diaporamas\Model\DiaporamaImage) { return $this->addUsingAlias(DiaporamaImageI18nTableMap::ID, $diaporamaImage->getId(), $comparison); } elseif ($diaporamaImage instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(DiaporamaImageI18nTableMap::ID, $diaporamaImage->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByDiaporamaImage() only accepts arguments of type \\Diaporamas\\Model\\DiaporamaImage or Collection'); } }
/** * Exclude object from result * * @param ChildDiaporamaImage $diaporamaImage Object to remove from the list of results * * @return ChildDiaporamaImageQuery The current query, for fluid interface */ public function prune($diaporamaImage = null) { if ($diaporamaImage) { $this->addUsingAlias(DiaporamaImageTableMap::ID, $diaporamaImage->getId(), Criteria::NOT_EQUAL); } return $this; }
/** * Declares an association between this object and a ChildDiaporamaImage object. * * @param ChildDiaporamaImage $v * @return \Diaporamas\Model\DiaporamaImageI18n The current object (for fluent API support) * @throws PropelException */ public function setDiaporamaImage(ChildDiaporamaImage $v = null) { if ($v === null) { $this->setId(NULL); } else { $this->setId($v->getId()); } $this->aDiaporamaImage = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildDiaporamaImage object, it will not be re-added. if ($v !== null) { $v->addDiaporamaImageI18n($this); } return $this; }