Restoired file events compatibility, factorised code
This commit is contained in:
@@ -11,167 +11,121 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Document;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
use Thelia\Core\Event\File\FileCreateOrUpdateEvent;
|
||||
use Thelia\Files\FileModelInterface;
|
||||
use Thelia\Model\CategoryDocument;
|
||||
use Thelia\Model\ContentDocument;
|
||||
use Thelia\Model\FolderDocument;
|
||||
use Thelia\Model\ProductDocument;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
* Date: 9/18/13
|
||||
* Time: 3:56 PM
|
||||
*
|
||||
* Occurring when a Document is saved
|
||||
* Occurring when an Document is saved
|
||||
*
|
||||
* @package Document
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
|
||||
*/
|
||||
class DocumentCreateOrUpdateEvent extends ActionEvent
|
||||
class DocumentCreateOrUpdateEvent extends FileCreateOrUpdateEvent
|
||||
{
|
||||
|
||||
/** @var CategoryDocument|ProductDocument|ContentDocument|FolderDocument model to save */
|
||||
protected $modelDocument = array();
|
||||
|
||||
/** @var CategoryDocument|ProductDocument|ContentDocument|FolderDocument model to save */
|
||||
protected $oldModelDocument = array();
|
||||
|
||||
/** @var UploadedFile Document file to save */
|
||||
protected $uploadedFile = null;
|
||||
|
||||
/** @var int Document parent id */
|
||||
protected $parentId = null;
|
||||
|
||||
/** @var string Parent name */
|
||||
protected $parentName = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $parentId Document parent id
|
||||
* @param string $documentType Document type
|
||||
* ex : FileManager::TYPE_CATEGORY
|
||||
* @param int $parentId Document parent id
|
||||
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
|
||||
*/
|
||||
public function __construct($parentId)
|
||||
public function __construct($documentType, $parentId)
|
||||
{
|
||||
$this->parentId = $parentId;
|
||||
parent::__construct($parentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $locale
|
||||
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
|
||||
*/
|
||||
public function setLocale($locale)
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
|
||||
*/
|
||||
public function getLocale()
|
||||
{
|
||||
throw new \RuntimeException("getLocale() is deprecated and no longer supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Document to save
|
||||
*
|
||||
* @param FileModelInterface $document Document to save
|
||||
* @param $document FileModelInterface
|
||||
*
|
||||
* @return $this
|
||||
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
|
||||
*/
|
||||
public function setModelDocument($document)
|
||||
{
|
||||
$this->modelDocument = $document;
|
||||
|
||||
return $this;
|
||||
parent::setModel($document);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Document being saved
|
||||
*
|
||||
* @return FileModelInterface
|
||||
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
|
||||
*/
|
||||
public function getModelDocument()
|
||||
{
|
||||
return $this->modelDocument;
|
||||
return parent::getModel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Document parent id
|
||||
* Set picture type
|
||||
*
|
||||
* @param int $parentId Document parent id
|
||||
* @param string $documentType Document type
|
||||
*
|
||||
* @return $this
|
||||
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
|
||||
*/
|
||||
public function setParentId($parentId)
|
||||
public function setDocumentType($documentType)
|
||||
{
|
||||
$this->parentId = $parentId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Document parent id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getParentId()
|
||||
{
|
||||
return $this->parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set uploaded file
|
||||
*
|
||||
* @param UploadedFile $uploadedFile File being uploaded
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUploadedFile($uploadedFile)
|
||||
{
|
||||
$this->uploadedFile = $uploadedFile;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get uploaded file
|
||||
*
|
||||
* @return UploadedFile
|
||||
*/
|
||||
public function getUploadedFile()
|
||||
{
|
||||
return $this->uploadedFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set parent name
|
||||
*
|
||||
* @param string $parentName Parent name
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setParentName($parentName)
|
||||
{
|
||||
$this->parentName = $parentName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent name
|
||||
* Get picture type
|
||||
*
|
||||
* @return string
|
||||
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
|
||||
*/
|
||||
public function getParentName()
|
||||
public function getDocumentType()
|
||||
{
|
||||
return $this->parentName;
|
||||
throw new \RuntimeException("getDocumentType() is deprecated and no longer supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set old model value
|
||||
*
|
||||
* @param FileModelInterface $oldModelDocument
|
||||
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
|
||||
*/
|
||||
public function setOldModelDocument($oldModelDocument)
|
||||
{
|
||||
$this->oldModelDocument = $oldModelDocument;
|
||||
parent::setOldModel($oldModelDocument);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get old model value
|
||||
*
|
||||
* @return FileModelInterface
|
||||
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
|
||||
*/
|
||||
public function getOldModelDocument()
|
||||
{
|
||||
return $this->oldModelDocument;
|
||||
return parent::getOldModel();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,11 @@
|
||||
|
||||
namespace Thelia\Core\Event\Document;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Files\FileModelInterface;
|
||||
use Thelia\Core\Event\Image\FileDeleteEvent;
|
||||
use Thelia\Model\CategoryDocument;
|
||||
use Thelia\Model\ContentDocument;
|
||||
use Thelia\Model\FolderDocument;
|
||||
use Thelia\Model\ProductDocument;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
@@ -24,34 +27,58 @@ use Thelia\Files\FileModelInterface;
|
||||
*
|
||||
* @package Document
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
* @deprecated deprecated since version 2.0.3. Use FileDeleteEvent instead
|
||||
*/
|
||||
class DocumentDeleteEvent extends ActionEvent
|
||||
class DocumentDeleteEvent extends FileDeleteEvent
|
||||
{
|
||||
|
||||
/** @var FileModelInterface Document about to be deleted */
|
||||
protected $documentToDelete = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param FileModelInterface $documentToDelete Document about to be deleted
|
||||
* @param CategoryDocument|ProductDocument|ContentDocument|FolderDocument $documentToDelete Document about to be deleted
|
||||
* @param string $documentType Document type
|
||||
* ex : FileManager::TYPE_CATEGORY
|
||||
* @deprecated deprecated since version 2.0.3. Use FileDeleteEvent instead
|
||||
*/
|
||||
public function __construct($documentToDelete)
|
||||
public function __construct($documentToDelete, $documentType)
|
||||
{
|
||||
$this->documentToDelete = $documentToDelete;
|
||||
parent::__construct($documentToDelete);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set picture type
|
||||
*
|
||||
* @param string $documentType Document type
|
||||
*
|
||||
* @return $this
|
||||
* @deprecated deprecated since version 2.0.3. Use FileDeleteEvent instead
|
||||
*/
|
||||
public function setDocumentType($documentType)
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get picture type
|
||||
*
|
||||
* @return string
|
||||
* @deprecated deprecated since version 2.0.3. Use FileDeleteEvent instead
|
||||
*/
|
||||
public function getDocumentType()
|
||||
{
|
||||
throw new \RuntimeException("getDocumentType() is deprecated and no longer supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Document about to be deleted
|
||||
*
|
||||
* @param FileModelInterface $documentToDelete Document about to be deleted
|
||||
* @param CategoryDocument|ProductDocument|ContentDocument|FolderDocument $documentToDelete Document about to be deleted
|
||||
*
|
||||
* @return $this
|
||||
* @deprecated deprecated since version 2.0.3. Use FileDeleteEvent instead
|
||||
*/
|
||||
public function setDocumentToDelete($documentToDelete)
|
||||
{
|
||||
$this->documentToDelete = $documentToDelete;
|
||||
parent::setFileToDelete($documentToDelete);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -59,11 +86,12 @@ class DocumentDeleteEvent extends ActionEvent
|
||||
/**
|
||||
* Get Document about to be deleted
|
||||
*
|
||||
* @return FileModelInterface
|
||||
* @return CategoryDocument|ProductDocument|ContentDocument|FolderDocument
|
||||
* @deprecated deprecated since version 2.0.3. Use FileDeleteEvent instead
|
||||
*/
|
||||
public function getDocumentToDelete()
|
||||
{
|
||||
return $this->documentToDelete;
|
||||
return parent::getFileToDelete();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
168
core/lib/Thelia/Core/Event/File/FileCreateOrUpdateEvent.php
Normal file
168
core/lib/Thelia/Core/Event/File/FileCreateOrUpdateEvent.php
Normal file
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\File;
|
||||
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Files\FileModelInterface;
|
||||
|
||||
/**
|
||||
* Event fired when a file is created or updated.
|
||||
*
|
||||
* @package Thelia\Core\Event\Document
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*
|
||||
*/
|
||||
class FileCreateOrUpdateEvent extends ActionEvent
|
||||
{
|
||||
/** @var FileModelInterface model to save */
|
||||
protected $model = array();
|
||||
|
||||
/** @var FileModelInterface model to save */
|
||||
protected $oldModel = array();
|
||||
|
||||
/** @var UploadedFile Document file to save */
|
||||
protected $uploadedFile = null;
|
||||
|
||||
/** @var int Document parent id */
|
||||
protected $parentId = null;
|
||||
|
||||
/** @var string Parent name */
|
||||
protected $parentName = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $parentId file parent id
|
||||
*/
|
||||
public function __construct($parentId)
|
||||
{
|
||||
$this->parentId = $parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set file to save
|
||||
*
|
||||
* @param FileModelInterface $model Document to save
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setModel($model)
|
||||
{
|
||||
$this->model = $model;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file being saved
|
||||
*
|
||||
* @return FileModelInterface
|
||||
*/
|
||||
public function getModel()
|
||||
{
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Document parent id
|
||||
*
|
||||
* @param int $parentId Document parent id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setParentId($parentId)
|
||||
{
|
||||
$this->parentId = $parentId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Document parent id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getParentId()
|
||||
{
|
||||
return $this->parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set uploaded file
|
||||
*
|
||||
* @param UploadedFile $uploadedFile File being uploaded
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUploadedFile($uploadedFile)
|
||||
{
|
||||
$this->uploadedFile = $uploadedFile;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get uploaded file
|
||||
*
|
||||
* @return UploadedFile
|
||||
*/
|
||||
public function getUploadedFile()
|
||||
{
|
||||
return $this->uploadedFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set parent name
|
||||
*
|
||||
* @param string $parentName Parent name
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setParentName($parentName)
|
||||
{
|
||||
$this->parentName = $parentName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getParentName()
|
||||
{
|
||||
return $this->parentName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set old model value
|
||||
*
|
||||
* @param FileModelInterface $oldModel
|
||||
*/
|
||||
public function setOldModel($oldModel)
|
||||
{
|
||||
$this->oldModel = $oldModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get old model value
|
||||
*
|
||||
* @return FileModelInterface
|
||||
*/
|
||||
public function getOldModel()
|
||||
{
|
||||
return $this->oldModel;
|
||||
}
|
||||
}
|
||||
62
core/lib/Thelia/Core/Event/File/FileDeleteEvent.php
Normal file
62
core/lib/Thelia/Core/Event/File/FileDeleteEvent.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Image;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Files\FileModelInterface;
|
||||
|
||||
/**
|
||||
* Event fired when a file is about to be deleted
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class FileDeleteEvent extends ActionEvent
|
||||
{
|
||||
/** @var FileModelInterface Image about to be deleted */
|
||||
protected $fileToDelete = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param FileModelInterface $fileToDelete Image about to be deleted
|
||||
*/
|
||||
public function __construct($fileToDelete)
|
||||
{
|
||||
$this->fileToDelete = $fileToDelete;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Image about to be deleted
|
||||
*
|
||||
* @param FileModelInterface $fileToDelete Image about to be deleted
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setFileToDelete($fileToDelete)
|
||||
{
|
||||
$this->fileToDelete = $fileToDelete;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image about to be deleted
|
||||
*
|
||||
* @return FileModelInterface
|
||||
*/
|
||||
public function getFileToDelete()
|
||||
{
|
||||
return $this->fileToDelete;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,8 +11,8 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Image;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
use Thelia\Core\Event\File\FileCreateOrUpdateEvent;
|
||||
use Thelia\Files\FileModelInterface;
|
||||
|
||||
/**
|
||||
@@ -24,170 +24,108 @@ use Thelia\Files\FileModelInterface;
|
||||
*
|
||||
* @package Image
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
|
||||
*/
|
||||
class ImageCreateOrUpdateEvent extends ActionEvent
|
||||
class ImageCreateOrUpdateEvent extends FileCreateOrUpdateEvent
|
||||
{
|
||||
|
||||
/** @var FileModelInterface model to save */
|
||||
protected $modelImage = array();
|
||||
|
||||
/** @var FileModelInterface model to save */
|
||||
protected $oldModelImage = array();
|
||||
|
||||
/** @var UploadedFile Image file to save */
|
||||
protected $uploadedFile = null;
|
||||
|
||||
/** @var int Image parent id */
|
||||
protected $parentId = null;
|
||||
|
||||
/** @var string Parent name */
|
||||
protected $parentName = null;
|
||||
|
||||
protected $locale;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $parentId Image parent id
|
||||
* @param string $imageType Image type
|
||||
* ex : FileManager::TYPE_CATEGORY
|
||||
* @param int $parentId Image parent id
|
||||
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
|
||||
*/
|
||||
public function __construct($parentId)
|
||||
public function __construct($imageType, $parentId)
|
||||
{
|
||||
$this->parentId = $parentId;
|
||||
parent::__construct($parentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $locale
|
||||
* @param mixed $locale
|
||||
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
|
||||
*/
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
|
||||
*/
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
throw new \RuntimeException("getLocale() is deprecated and no longer supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Image to save
|
||||
*
|
||||
* @param FileModelInterface $image
|
||||
* @param $image FileModelInterface
|
||||
*
|
||||
* @return $this
|
||||
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
|
||||
*/
|
||||
public function setModelImage($image)
|
||||
{
|
||||
$this->modelImage = $image;
|
||||
|
||||
return $this;
|
||||
parent::setModel($image);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image being saved
|
||||
*
|
||||
* @return FileModelInterface
|
||||
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
|
||||
*/
|
||||
public function getModelImage()
|
||||
{
|
||||
return $this->modelImage;
|
||||
return parent::getModel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Image parent id
|
||||
* Set picture type
|
||||
*
|
||||
* @param int $parentId Image parent id
|
||||
* @param string $imageType Image type
|
||||
*
|
||||
* @return $this
|
||||
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
|
||||
*/
|
||||
public function setParentId($parentId)
|
||||
public function setImageType($imageType)
|
||||
{
|
||||
$this->parentId = $parentId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image parent id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getParentId()
|
||||
{
|
||||
return $this->parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set uploaded file
|
||||
*
|
||||
* @param UploadedFile $uploadedFile File being uploaded
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUploadedFile($uploadedFile)
|
||||
{
|
||||
$this->uploadedFile = $uploadedFile;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get uploaded file
|
||||
*
|
||||
* @return UploadedFile
|
||||
*/
|
||||
public function getUploadedFile()
|
||||
{
|
||||
return $this->uploadedFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set parent name
|
||||
*
|
||||
* @param string $parentName Parent name
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setParentName($parentName)
|
||||
{
|
||||
$this->parentName = $parentName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent name
|
||||
* Get picture type
|
||||
*
|
||||
* @return string
|
||||
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
|
||||
*/
|
||||
public function getParentName()
|
||||
public function getImageType()
|
||||
{
|
||||
return $this->parentName;
|
||||
throw new \RuntimeException("getImageType() is deprecated and no longer supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set old model value
|
||||
*
|
||||
* @param \Thelia\Model\CategoryImage|\Thelia\Model\ContentImage|\Thelia\Model\FolderImage|\Thelia\Model\ProductImage $oldModelImage
|
||||
* @param FileModelInterface $oldModelImage
|
||||
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
|
||||
*/
|
||||
public function setOldModelImage($oldModelImage)
|
||||
{
|
||||
$this->oldModelImage = $oldModelImage;
|
||||
parent::setOldModel($oldModelImage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get old model value
|
||||
*
|
||||
* @return \Thelia\Model\CategoryImage|\Thelia\Model\ContentImage|\Thelia\Model\FolderImage|\Thelia\Model\ProductImage
|
||||
* @return FileModelInterface
|
||||
* @deprecated deprecated since version 2.0.3. Use FileCreateOrUpdateEvent instead
|
||||
*/
|
||||
public function getOldModelImage()
|
||||
{
|
||||
return $this->oldModelImage;
|
||||
return parent::getOldModel();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,8 +12,10 @@
|
||||
|
||||
namespace Thelia\Core\Event\Image;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Files\FileModelInterface;
|
||||
use Thelia\Model\CategoryImage;
|
||||
use Thelia\Model\ContentImage;
|
||||
use Thelia\Model\FolderImage;
|
||||
use Thelia\Model\ProductImage;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
@@ -24,36 +26,58 @@ use Thelia\Files\FileModelInterface;
|
||||
*
|
||||
* @package Image
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
* @deprecated deprecated since version 2.0.3. Use FileDeleteEvent instead
|
||||
*/
|
||||
class ImageDeleteEvent extends ActionEvent
|
||||
class ImageDeleteEvent extends FileDeleteEvent
|
||||
{
|
||||
/** @var string Image type */
|
||||
protected $imageType = null;
|
||||
|
||||
/** @var FileModelInterface Image about to be deleted */
|
||||
protected $imageToDelete = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param FileModelInterface $imageToDelete Image about to be deleted
|
||||
* @param CategoryImage|ProductImage|ContentImage|FolderImage $imageToDelete Image about to be deleted
|
||||
* @param string $imageType Image type
|
||||
* ex : FileManager::TYPE_CATEGORY
|
||||
* @deprecated deprecated since version 2.0.3. Use FileDeleteEvent instead
|
||||
*/
|
||||
public function __construct($imageToDelete)
|
||||
public function __construct($imageToDelete, $imageType)
|
||||
{
|
||||
$this->imageToDelete = $imageToDelete;
|
||||
parent::__construct($imageToDelete);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set picture type
|
||||
*
|
||||
* @param string $imageType Image type
|
||||
*
|
||||
* @return $this
|
||||
* @deprecated deprecated since version 2.0.3. Use FileDeleteEvent instead
|
||||
*/
|
||||
public function setImageType($imageType)
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get picture type
|
||||
*
|
||||
* @return string
|
||||
* @deprecated deprecated since version 2.0.3. Use FileDeleteEvent instead
|
||||
*/
|
||||
public function getImageType()
|
||||
{
|
||||
throw new \RuntimeException("getImageType() is deprecated and no longer supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Image about to be deleted
|
||||
*
|
||||
* @param FileModelInterface $imageToDelete Image about to be deleted
|
||||
* @param CategoryImage|ProductImage|ContentImage|FolderImage $imageToDelete Image about to be deleted
|
||||
*
|
||||
* @return $this
|
||||
* @deprecated deprecated since version 2.0.3. Use FileDeleteEvent instead
|
||||
*/
|
||||
public function setImageToDelete($imageToDelete)
|
||||
{
|
||||
$this->imageToDelete = $imageToDelete;
|
||||
parent::setFileToDelete($imageToDelete);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -61,11 +85,12 @@ class ImageDeleteEvent extends ActionEvent
|
||||
/**
|
||||
* Get Image about to be deleted
|
||||
*
|
||||
* @return FileModelInterface
|
||||
* @return CategoryImage|ProductImage|ContentImage|FolderImage
|
||||
* @deprecated deprecated since version 2.0.3. Use FileDeleteEvent instead
|
||||
*/
|
||||
public function getImageToDelete()
|
||||
{
|
||||
return $this->imageToDelete;
|
||||
return parent::getFileToDelete();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user