WIP : upload documents : add action, ctrl, event
This commit is contained in:
217
core/lib/Thelia/Core/Event/DocumentCreateOrUpdateEvent.php
Executable file
217
core/lib/Thelia/Core/Event/DocumentCreateOrUpdateEvent.php
Executable file
@@ -0,0 +1,217 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
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
|
||||
*
|
||||
* @package Document
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class DocumentCreateOrUpdateEvent extends ActionEvent
|
||||
{
|
||||
|
||||
/** @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 Document type */
|
||||
protected $documentType = null;
|
||||
|
||||
/** @var string Parent name */
|
||||
protected $parentName = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $documentType Document type
|
||||
* ex : FileManager::TYPE_CATEGORY
|
||||
* @param int $parentId Document parent id
|
||||
*/
|
||||
public function __construct($documentType, $parentId)
|
||||
{
|
||||
$this->imageType = $documentType;
|
||||
$this->parentId = $parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Document to save
|
||||
*
|
||||
* @param CategoryDocument|ProductDocument|ContentDocument|FolderDocument $document Document to save
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setModelDocument($document)
|
||||
{
|
||||
$this->modelDocument = $document;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Document being saved
|
||||
*
|
||||
* @return CategoryDocument|ProductDocument|ContentDocument|FolderDocument
|
||||
*/
|
||||
public function getModelDocument()
|
||||
{
|
||||
return $this->modelDocument;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set document type
|
||||
*
|
||||
* @param string $documentType Document type
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDocumentType($documentType)
|
||||
{
|
||||
$this->imageType = $documentType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get document type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDocumentType()
|
||||
{
|
||||
return $this->documentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 CategoryDocument|ContentDocument|FolderDocument|ProductDocument $oldModelDocument
|
||||
*/
|
||||
public function setOldModelDocument($oldModelDocument)
|
||||
{
|
||||
$this->oldModelDocument = $oldModelDocument;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get old model value
|
||||
*
|
||||
* @return CategoryDocument|ContentDocument|FolderDocument|ProductDocument
|
||||
*/
|
||||
public function getOldModelDocument()
|
||||
{
|
||||
return $this->oldModelDocument;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
112
core/lib/Thelia/Core/Event/DocumentDeleteEvent.php
Executable file
112
core/lib/Thelia/Core/Event/DocumentDeleteEvent.php
Executable file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
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 about to be deleted
|
||||
*
|
||||
* @package Document
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class DocumentDeleteEvent extends ActionEvent
|
||||
{
|
||||
/** @var string Document type */
|
||||
protected $documentType = null;
|
||||
|
||||
/** @var CategoryDocument|ProductDocument|ContentDocument|FolderDocument Document about to be deleted */
|
||||
protected $documentToDelete = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param CategoryDocument|ProductDocument|ContentDocument|FolderDocument $documentToDelete Document about to be deleted
|
||||
* @param string $documentType Document type
|
||||
* ex : FileManager::TYPE_CATEGORY
|
||||
*/
|
||||
public function __construct($documentToDelete, $documentType)
|
||||
{
|
||||
$this->imageToDelete = $documentToDelete;
|
||||
$this->documentType = $documentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set picture type
|
||||
*
|
||||
* @param string $documentType Document type
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDocumentType($documentType)
|
||||
{
|
||||
$this->documentType = $documentType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get picture type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDocumentType()
|
||||
{
|
||||
return $this->documentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Document about to be deleted
|
||||
*
|
||||
* @param CategoryDocument|ProductDocument|ContentDocument|FolderDocument $documentToDelete Document about to be deleted
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDocumentToDelete($documentToDelete)
|
||||
{
|
||||
$this->imageToDelete = $documentToDelete;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Document about to be deleted
|
||||
*
|
||||
* @return CategoryDocument|ProductDocument|ContentDocument|FolderDocument
|
||||
*/
|
||||
public function getDocumentToDelete()
|
||||
{
|
||||
return $this->documentToDelete;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,184 +0,0 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
* Date: 9/18/13
|
||||
* Time: 3:56 PM
|
||||
*
|
||||
* Occurring when a Image list is saved
|
||||
*
|
||||
* @package Image
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class ImagesCreateOrUpdateEvent extends ActionEvent
|
||||
{
|
||||
CONST TYPE_PRODUCT = 'product';
|
||||
CONST TYPE_CATEGORY = 'category';
|
||||
CONST TYPE_CONTENT = 'content';
|
||||
CONST TYPE_FOLDER = 'folder';
|
||||
|
||||
/** @var array Images model to save */
|
||||
protected $modelImages = array();
|
||||
|
||||
/** @var array Images file to save */
|
||||
protected $uploadedFiles = array();
|
||||
|
||||
/** @var int Image parent id */
|
||||
protected $parentId = null;
|
||||
|
||||
/** @var string Image type */
|
||||
protected $imageType = null;
|
||||
|
||||
/** @var array Available image parent type */
|
||||
protected static $availableType = array(
|
||||
self::TYPE_PRODUCT,
|
||||
self::TYPE_CATEGORY,
|
||||
self::TYPE_CONTENT,
|
||||
self::TYPE_FOLDER,
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $pictureType Picture type
|
||||
* ex : ImageCreateOrUpdateEvent::TYPE_CATEGORY
|
||||
* @param int $parentId Image parent id
|
||||
*/
|
||||
public function __construct($pictureType, $parentId)
|
||||
{
|
||||
$this->imageType = $pictureType;
|
||||
$this->parentId = $parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Images to save
|
||||
*
|
||||
* @param array $images Thelia\Model\CategoryImage Array
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setModelImages($images)
|
||||
{
|
||||
$this->modelImages = $images;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Images being saved
|
||||
*
|
||||
* @return array Array of Thelia\Model\CategoryImage
|
||||
*/
|
||||
public function getModelImages()
|
||||
{
|
||||
return $this->modelImages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Images to save
|
||||
*
|
||||
* @param array $images Thelia\Model\CategoryImage Array
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUploadedFiles($images)
|
||||
{
|
||||
$this->uploadedFiles = $images;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Images being saved
|
||||
*
|
||||
* @return array Array of Thelia\Model\CategoryImage
|
||||
*/
|
||||
public function getUploadedFiles()
|
||||
{
|
||||
return $this->uploadedFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set picture type
|
||||
*
|
||||
* @param string $pictureType Picture type
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setImageType($pictureType)
|
||||
{
|
||||
$this->imageType = $pictureType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get picture type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getImageType()
|
||||
{
|
||||
return $this->imageType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all image parent type available
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getAvailableType()
|
||||
{
|
||||
return self::$availableType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Image parent id
|
||||
*
|
||||
* @param int $parentId Image parent id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setParentId($parentId)
|
||||
{
|
||||
$this->parentId = $parentId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image parent id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getParentId()
|
||||
{
|
||||
return $this->parentId;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -337,6 +337,26 @@ final class TheliaEvents
|
||||
*/
|
||||
const DOCUMENT_PROCESS = "action.processDocument";
|
||||
|
||||
/**
|
||||
* Sent on image cache clear request
|
||||
*/
|
||||
const DOCUMENT_CLEAR_CACHE = "action.clearDocumentCache";
|
||||
|
||||
/**
|
||||
* Save given documents
|
||||
*/
|
||||
const DOCUMENT_SAVE = "action.saveDocument";
|
||||
|
||||
/**
|
||||
* Save given documents
|
||||
*/
|
||||
const DOCUMENT_UPDATE = "action.updateDocument";
|
||||
|
||||
/**
|
||||
* Delete given document
|
||||
*/
|
||||
const DOCUMENT_DELETE = "action.deleteDocument";
|
||||
|
||||
/**
|
||||
* Sent on image cache clear request
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user