diff --git a/core/lib/Thelia/Model/Category.php b/core/lib/Thelia/Model/Category.php index c5ab471a5..298650626 100644 --- a/core/lib/Thelia/Model/Category.php +++ b/core/lib/Thelia/Model/Category.php @@ -3,18 +3,22 @@ namespace Thelia\Model; use Thelia\Core\Event\Category\CategoryEvent; +use Thelia\Files\FileModelParentInterface; use Thelia\Model\Base\Category as BaseCategory; use Thelia\Core\Event\TheliaEvents; use Propel\Runtime\Connection\ConnectionInterface; +use Thelia\Model\Tools\ModelEventDispatcherTrait; +use Thelia\Model\Tools\PositionManagementTrait; +use Thelia\Model\Tools\UrlRewritingTrait; -class Category extends BaseCategory +class Category extends BaseCategory implements FileModelParentInterface { - use \Thelia\Model\Tools\ModelEventDispatcherTrait; + use ModelEventDispatcherTrait; - use \Thelia\Model\Tools\PositionManagementTrait; + use PositionManagementTrait; - use \Thelia\Model\Tools\UrlRewritingTrait; + use UrlRewritingTrait; /** * @return int number of child for the current category diff --git a/core/lib/Thelia/Model/CategoryDocument.php b/core/lib/Thelia/Model/CategoryDocument.php index 4b20d8a59..3e13863bb 100644 --- a/core/lib/Thelia/Model/CategoryDocument.php +++ b/core/lib/Thelia/Model/CategoryDocument.php @@ -2,16 +2,22 @@ namespace Thelia\Model; +use Propel\Runtime\ActiveQuery\ModelCriteria; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Routing\Router; +use Thelia\Core\HttpFoundation\Request; +use Thelia\Files\FileModelParentInterface; +use Thelia\Form\BaseForm; +use Thelia\Form\CategoryDocumentModification; use Thelia\Model\Base\CategoryDocument as BaseCategoryDocument; use Propel\Runtime\Connection\ConnectionInterface; use Thelia\Model\Breadcrumb\BreadcrumbInterface; use Thelia\Model\Breadcrumb\CatalogBreadcrumbTrait; +use Thelia\Files\FileModelInterface; use Thelia\Model\Tools\PositionManagementTrait; use Thelia\Model\Tools\ModelEventDispatcherTrait; -class CategoryDocument extends BaseCategoryDocument implements BreadcrumbInterface +class CategoryDocument extends BaseCategoryDocument implements BreadcrumbInterface, FileModelInterface { use ModelEventDispatcherTrait; use PositionManagementTrait; @@ -19,6 +25,8 @@ class CategoryDocument extends BaseCategoryDocument implements BreadcrumbInterfa /** * Calculate next position relative to our parent + * + * @param CategoryDocumentQuery $query */ protected function addCriteriaToPositionQuery($query) { @@ -36,11 +44,7 @@ class CategoryDocument extends BaseCategoryDocument implements BreadcrumbInterfa } /** - * Set Document parent id - * - * @param int $parentId parent id - * - * @return $this + * @inheritdoc */ public function setParentId($parentId) { @@ -50,9 +54,7 @@ class CategoryDocument extends BaseCategoryDocument implements BreadcrumbInterfa } /** - * Get Document parent id - * - * @return int parent id + * @inheritdoc */ public function getParentId() { @@ -71,13 +73,68 @@ class CategoryDocument extends BaseCategoryDocument implements BreadcrumbInterfa } /** - * - * return the complete breadcrumb for a given resource. - * - * @return array + * @inheritdoc */ - public function getBreadcrumb(Router $router, ContainerInterface $container, $tab) + public function getBreadcrumb(Router $router, ContainerInterface $container, $tab, $locale) { - return $this->getCategoryBreadcrumb($router, $container, $tab); + return $this->getCategoryBreadcrumb($router, $container, $tab, $locale); + } + + /** + * @return FileModelParentInterface the parent file model + */ + public function getParentFileModel() + { + return new Category(); + } + + /** + * Get the ID of the form used to change this object information + * + * @return BaseForm the form + */ + public function getUpdateFormId() + { + return 'thelia.admin.category.document.modification'; + } + + /** + * Get the form instance used to change this object information + * + * @param \Thelia\Core\HttpFoundation\Request $request + * + * @return BaseForm the form + */ + public function getUpdateFormInstance(Request $request) + { + return new CategoryDocumentModification($request); + } + + /** + * @return string the path to the upload directory where files are stored, without final slash + */ + public function getUploadDir() + { + return THELIA_LOCAL_DIR . 'media'.DS.'documents'.DS.'category'; + } + + /** + * @param int $objectId the ID of the object + * + * @return string the URL to redirect to after update from the back-office + */ + public function getRedirectionUrl($objectId) + { + return '/admin/categories/update?category_id=' . $objectId . '?current_tab=document'; + } + + /** + * Get the Query instance for this object + * + * @return ModelCriteria + */ + public function getQueryInstance() + { + return CategoryDocumentQuery::create(); } }