filterById($this->getId()); } /** * @inheritDoc */ public function preInsert(ConnectionInterface $con = null) { $lastImage = SelectionImageQuery::create() ->filterBySelectionId( $this->getSelectionContainerId() ) ->orderByPosition(Criteria::DESC) ->findOne(); if (null !== $lastImage) { $position = $lastImage->getPosition() + 1; } else { $position = 1; } $this->setPosition($position); return true; } public function setParentId($parentId) { $this->setSelectionContainerId($parentId); return $this; } public function getUpdateFormId() { return 'admin.selection.image.modification'; } public function getUploadDir() { $uploadDir = ConfigQuery::read('images_library_path'); if ($uploadDir === null) { $uploadDir = THELIA_LOCAL_DIR . 'media' . DS . 'images'; } else { $uploadDir = THELIA_ROOT . $uploadDir; } return $uploadDir . DS . strtolower(SelectionContainer::IMAGE_TYPE_LABEL); } public function getRedirectionUrl() { return '/admin/selection/container/update/' . $this->getSelectionContainerId(); } public function getParentId() { return $this->getId(); } public function getParentFileModel() { return new SelectionContainer(); } public function getQueryInstance() { return SelectionContainerImageQuery::create(); } /** * @param Router $router * @param ContainerInterface $container * @param string $tab * @param string $locale * @return array|mixed * @throws \Propel\Runtime\Exception\PropelException */ public function getBreadcrumb(Router $router, ContainerInterface $container, $tab, $locale) { /** @var SelectionContainerImage $selectionContainer */ $selectionContainer = $this->getSelectionContainer(); $selectionContainer->setLocale($locale); $breadcrumb[$selectionContainer->getTitle()] = sprintf( "%s?current_tab=%s", $router->generate( 'admin.selection.container.view', ['selectionContainerId' => $selectionContainer->getId()], Router::ABSOLUTE_URL ), $tab ); return $breadcrumb; } }