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\ContentImageModification;
use Thelia\Model\Base\ContentImage as BaseContentImage;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Model\Breadcrumb\BreadcrumbInterface;
use Thelia\Model\Breadcrumb\FolderBreadcrumbTrait;
use Thelia\Files\FileModelInterface;
class ContentImage extends BaseContentImage implements BreadcrumbInterface
class ContentImage extends BaseContentImage implements BreadcrumbInterface, FileModelInterface
{
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
use \Thelia\Model\Tools\PositionManagementTrait;
@@ -17,6 +23,8 @@ class ContentImage extends BaseContentImage implements BreadcrumbInterface
/**
* Calculate next position relative to our parent
*
* @param ContentImageQuery $query
*/
protected function addCriteriaToPositionQuery($query)
{
@@ -34,11 +42,7 @@ class ContentImage extends BaseContentImage implements BreadcrumbInterface
}
/**
* Set Image parent id
*
* @param int $parentId parent id
*
* @return $this
* @inheritdoc
*/
public function setParentId($parentId)
{
@@ -48,9 +52,7 @@ class ContentImage extends BaseContentImage implements BreadcrumbInterface
}
/**
* Get Image parent id
*
* @return int parent id
* @inheritdoc
*/
public function getParentId()
{
@@ -69,13 +71,69 @@ class ContentImage extends BaseContentImage implements BreadcrumbInterface
}
/**
*
* 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->getContentBreadcrumb($router, $container, $tab);
return $this->getContentBreadcrumb($router, $container, $tab, $locale);
}
/**
* @return FileModelParentInterface the parent file model
*/
public function getParentFileModel()
{
return new Content();
}
/**
* Get the ID of the form used to change this object information
*
* @return BaseForm the form
*/
public function getUpdateFormId()
{
return 'thelia.admin.content.image.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 ContentImageModification($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.'images'.DS.'content';
}
/**
* @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/content/update/' . $objectId . '?current_tab=image';
}
/**
* Get the Query instance for this object
*
* @return ModelCriteria
*/
public function getQueryInstance()
{
return ContentImageQuery::create();
}
}