Refactoring of images and documents management

This commit is contained in:
Franck Allimant
2014-06-26 10:36:12 +02:00
parent b49f8a6423
commit 114a55c1e8
33 changed files with 1795 additions and 2216 deletions

View File

@@ -2,14 +2,20 @@
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\FolderDocumentModification;
use Thelia\Model\Base\FolderDocument as BaseFolderDocument;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Model\Breadcrumb\BreadcrumbInterface;
use Thelia\Model\Breadcrumb\FolderBreadcrumbTrait;
use Thelia\Files\FileModelInterface;
class FolderDocument extends BaseFolderDocument implements BreadcrumbInterface
class FolderDocument extends BaseFolderDocument implements BreadcrumbInterface, FileModelInterface
{
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
use \Thelia\Model\Tools\PositionManagementTrait;
@@ -17,6 +23,8 @@ class FolderDocument extends BaseFolderDocument implements BreadcrumbInterface
/**
* Calculate next position relative to our parent
*
* @param FolderDocumentQuery $query
*/
protected function addCriteriaToPositionQuery($query)
{
@@ -34,11 +42,7 @@ class FolderDocument extends BaseFolderDocument implements BreadcrumbInterface
}
/**
* Set Document parent id
*
* @param int $parentId parent id
*
* @return $this
* @inheritdoc
*/
public function setParentId($parentId)
{
@@ -48,9 +52,7 @@ class FolderDocument extends BaseFolderDocument implements BreadcrumbInterface
}
/**
* Get Document parent id
*
* @return int parent id
* @inheritdoc
*/
public function getParentId()
{
@@ -68,8 +70,68 @@ class FolderDocument extends BaseFolderDocument implements BreadcrumbInterface
return true;
}
public function getBreadcrumb(Router $router, ContainerInterface $container, $tab)
/**
* @inheritdoc
*/
public function getBreadcrumb(Router $router, ContainerInterface $container, $tab, $locale)
{
return $this->getFolderBreadcrumb($router, $container, $tab);
return $this->getFolderBreadcrumb($router, $container, $tab, $locale);
}
/**
* @return FileModelParentInterface the parent file model
*/
public function getParentFileModel()
{
return new Folder();
}
/**
* Get the ID of the form used to change this object information
*
* @return BaseForm the form
*/
public function getUpdateFormId()
{
return 'thelia.admin.folder.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 FolderDocumentModification($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.'folder';
}
/**
* @param int $objectId the ID of the parent object
* @return string the URL to redirect to after update from the back-office
*/
public function getRedirectionUrl($objectId)
{
return '/admin/folder/update/' . $objectId . '?current_tab=image';
}
/**
* Get the Query instance for this object
*
* @return ModelCriteria
*/
public function getQueryInstance()
{
return FolderDocumentQuery::create();
}
}