/**
  * 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');
     }
 }
 /**
  * Use this method in order to add fields in sub-classes
  * @param LoopResultRow $loopResultRow
  * @param \Diaporamas\Model\DiaporamaImage $item
  *
  */
 protected function addOutputFields(LoopResultRow $loopResultRow, $item)
 {
     $loopResultRow->set('OBJECT_ID', $item->getDiaporamaId());
 }
 protected function createOrUpdate(DiaporamaImageEvent $event, DiaporamaImage $model)
 {
     $con = Propel::getConnection(DiaporamaImageTableMap::DATABASE_NAME);
     $con->beginTransaction();
     try {
         $model->setLocale($event->getLocale());
         if (null !== ($id = $event->getId())) {
             $model->setId($id);
         }
         if (null !== ($diaporamaId = $event->getDiaporamaId())) {
             $model->setDiaporamaId($diaporamaId);
         }
         if (null !== ($file = $event->getFile())) {
             $model->setFile($file);
         }
         if (null !== ($visible = $event->getVisible())) {
             $model->setVisible($visible);
         }
         if (null !== ($position = $event->getPosition())) {
             $model->setPosition($position);
         }
         if (null !== ($title = $event->getTitle())) {
             $model->setTitle($title);
         }
         if (null !== ($description = $event->getDescription())) {
             $model->setDescription($description);
         }
         if (null !== ($chapo = $event->getChapo())) {
             $model->setChapo($chapo);
         }
         if (null !== ($postscriptum = $event->getPostscriptum())) {
             $model->setPostscriptum($postscriptum);
         }
         $model->save($con);
         $con->commit();
     } catch (\Exception $e) {
         $con->rollback();
         throw $e;
     }
     $event->setDiaporamaImage($model);
 }
 /**
  * Filter the query by a related \Diaporamas\Model\DiaporamaImage object
  *
  * @param \Diaporamas\Model\DiaporamaImage|ObjectCollection $diaporamaImage  the related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildDiaporamaQuery The current query, for fluid interface
  */
 public function filterByDiaporamaImage($diaporamaImage, $comparison = null)
 {
     if ($diaporamaImage instanceof \Diaporamas\Model\DiaporamaImage) {
         return $this->addUsingAlias(DiaporamaTableMap::ID, $diaporamaImage->getDiaporamaId(), $comparison);
     } elseif ($diaporamaImage instanceof ObjectCollection) {
         return $this->useDiaporamaImageQuery()->filterByPrimaryKeys($diaporamaImage->getPrimaryKeys())->endUse();
     } 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;
 }