ltsecurityinc安防产品在线商城代码
This commit is contained in:
Executable
+162
@@ -0,0 +1,162 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Olegnax\Carousel\Model;
|
||||
|
||||
use Magento\Framework\Api\DataObjectHelper;
|
||||
use Magento\Framework\Model\AbstractModel;
|
||||
use Magento\Framework\Model\Context;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
use Olegnax\Carousel\Api\Data\CarouselInterface;
|
||||
use Olegnax\Carousel\Api\Data\CarouselInterfaceFactory;
|
||||
use Olegnax\Carousel\Model\ResourceModel\Carousel\Collection;
|
||||
use Olegnax\Carousel\Model\ResourceModel\Slide\CollectionFactory;
|
||||
|
||||
|
||||
class Carousel extends AbstractModel
|
||||
{
|
||||
|
||||
const UPDATE_TIME = 'update_time';
|
||||
protected $_eventPrefix = 'olegnax_carousel_carousel';
|
||||
/**
|
||||
* @var CarouselInterfaceFactory
|
||||
*/
|
||||
protected $carouselDataFactory;
|
||||
|
||||
/**
|
||||
* @var DataObjectHelper
|
||||
*/
|
||||
protected $dataObjectHelper;
|
||||
/**
|
||||
* @var StoreManagerInterface
|
||||
*/
|
||||
protected $_storeManager;
|
||||
/**
|
||||
* @var CollectionFactory
|
||||
*/
|
||||
private $slideFactory;
|
||||
|
||||
/**
|
||||
* Carousel constructor.
|
||||
* @param Context $context
|
||||
* @param Registry $registry
|
||||
* @param CarouselInterfaceFactory $carouselDataFactory
|
||||
* @param DataObjectHelper $dataObjectHelper
|
||||
* @param ResourceModel\Carousel $resource
|
||||
* @param StoreManagerInterface $storeManager
|
||||
* @param CollectionFactory $slideFactory
|
||||
* @param Collection $resourceCollection
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Registry $registry,
|
||||
CarouselInterfaceFactory $carouselDataFactory,
|
||||
DataObjectHelper $dataObjectHelper,
|
||||
ResourceModel\Carousel $resource,
|
||||
StoreManagerInterface $storeManager,
|
||||
CollectionFactory $slideFactory,
|
||||
Collection $resourceCollection,
|
||||
array $data = []
|
||||
) {
|
||||
$this->_storeManager = $storeManager;
|
||||
$this->carouselDataFactory = $carouselDataFactory;
|
||||
$this->slideFactory = $slideFactory;
|
||||
$this->dataObjectHelper = $dataObjectHelper;
|
||||
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve carousel model with carousel data
|
||||
* @return CarouselInterface
|
||||
*/
|
||||
public function getDataModel()
|
||||
{
|
||||
$carouselData = $this->getData();
|
||||
|
||||
$carouselDataObject = $this->carouselDataFactory->create();
|
||||
$this->dataObjectHelper->populateWithArray(
|
||||
$carouselDataObject,
|
||||
$carouselData,
|
||||
CarouselInterface::class
|
||||
);
|
||||
|
||||
return $carouselDataObject;
|
||||
}
|
||||
|
||||
public function beforeSave()
|
||||
{
|
||||
if ($this->hasDataChanges()) {
|
||||
$this->setUpdateTime(date('Y-m-d H:i:s'));
|
||||
}
|
||||
|
||||
parent::beforeSave();
|
||||
}
|
||||
|
||||
public function setUpdateTime($updateTime)
|
||||
{
|
||||
return $this->setData(self::UPDATE_TIME, $updateTime);
|
||||
}
|
||||
|
||||
public function getSlide($store_id = null)
|
||||
{
|
||||
return $this->getAllActiveSlide()
|
||||
->addStoreFilter($store_id ? $this->_storeManager->getStore($store_id) : null);
|
||||
}
|
||||
|
||||
public function getAllActiveSlide()
|
||||
{
|
||||
return $this->getAllSlide()
|
||||
->addFieldToFilter('is_active', '1');
|
||||
}
|
||||
|
||||
public function getAllSlide()
|
||||
{
|
||||
return $this->slideFactory->create()->addFieldToSelect('*')
|
||||
->addFieldToFilter('carousel', $this->getData('identifier'))
|
||||
->setOrder('sort_order', 'asc');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return current store id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getStoreId()
|
||||
{
|
||||
return $this->_storeManager->getStore()->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Model construct that should be used for object initialization
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init(ResourceModel\Carousel::class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Olegnax\Carousel\Model\Carousel;
|
||||
|
||||
use Magento\Framework\App\Request\DataPersistorInterface;
|
||||
use Magento\Ui\DataProvider\AbstractDataProvider;
|
||||
use Olegnax\Carousel\Model\ResourceModel\Carousel\CollectionFactory;
|
||||
|
||||
|
||||
class DataProvider extends AbstractDataProvider
|
||||
{
|
||||
|
||||
protected $dataPersistor;
|
||||
|
||||
protected $collection;
|
||||
|
||||
protected $loadedData;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $primaryFieldName
|
||||
* @param string $requestFieldName
|
||||
* @param CollectionFactory $collectionFactory
|
||||
* @param DataPersistorInterface $dataPersistor
|
||||
* @param array $meta
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
$name,
|
||||
$primaryFieldName,
|
||||
$requestFieldName,
|
||||
CollectionFactory $collectionFactory,
|
||||
DataPersistorInterface $dataPersistor,
|
||||
array $meta = [],
|
||||
array $data = []
|
||||
) {
|
||||
$this->collection = $collectionFactory->create();
|
||||
$this->dataPersistor = $dataPersistor;
|
||||
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
if (isset($this->loadedData)) {
|
||||
return $this->loadedData;
|
||||
}
|
||||
$items = $this->collection->getItems();
|
||||
foreach ($items as $model) {
|
||||
$this->loadedData[$model->getId()] = $model->getData();
|
||||
}
|
||||
$data = $this->dataPersistor->get('olegnax_carousel_carousel');
|
||||
|
||||
if (!empty($data)) {
|
||||
$model = $this->collection->getNewEmptyItem();
|
||||
$model->setData($data);
|
||||
$this->loadedData[$model->getId()] = $model->getData();
|
||||
$this->dataPersistor->clear('olegnax_carousel_carousel');
|
||||
}
|
||||
|
||||
return $this->loadedData;
|
||||
}
|
||||
}
|
||||
|
||||
+200
@@ -0,0 +1,200 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Olegnax\Carousel\Model;
|
||||
|
||||
use Exception;
|
||||
use Magento\Framework\Api\DataObjectHelper;
|
||||
use Magento\Framework\Api\ExtensibleDataObjectConverter;
|
||||
use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;
|
||||
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
|
||||
use Magento\Framework\Api\SearchCriteriaInterface;
|
||||
use Magento\Framework\Exception\CouldNotDeleteException;
|
||||
use Magento\Framework\Exception\CouldNotSaveException;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Framework\Reflection\DataObjectProcessor;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
use Olegnax\Carousel\Api\CarouselRepositoryInterface;
|
||||
use Olegnax\Carousel\Api\Data\CarouselInterface;
|
||||
use Olegnax\Carousel\Api\Data\CarouselInterfaceFactory;
|
||||
use Olegnax\Carousel\Api\Data\CarouselSearchResultsInterfaceFactory;
|
||||
use Olegnax\Carousel\Model\ResourceModel\Carousel as ResourceCarousel;
|
||||
use Olegnax\Carousel\Model\ResourceModel\Carousel\CollectionFactory as CarouselCollectionFactory;
|
||||
|
||||
|
||||
class CarouselRepository implements CarouselRepositoryInterface
|
||||
{
|
||||
|
||||
protected $extensionAttributesJoinProcessor;
|
||||
|
||||
protected $dataCarouselFactory;
|
||||
|
||||
protected $searchResultsFactory;
|
||||
protected $dataObjectProcessor;
|
||||
protected $dataObjectHelper;
|
||||
protected $carouselCollectionFactory;
|
||||
protected $extensibleDataObjectConverter;
|
||||
protected $resource;
|
||||
protected $carouselFactory;
|
||||
private $storeManager;
|
||||
private $collectionProcessor;
|
||||
|
||||
|
||||
/**
|
||||
* @param ResourceCarousel $resource
|
||||
* @param CarouselFactory $carouselFactory
|
||||
* @param CarouselInterfaceFactory $dataCarouselFactory
|
||||
* @param CarouselCollectionFactory $carouselCollectionFactory
|
||||
* @param CarouselSearchResultsInterfaceFactory $searchResultsFactory
|
||||
* @param DataObjectHelper $dataObjectHelper
|
||||
* @param DataObjectProcessor $dataObjectProcessor
|
||||
* @param StoreManagerInterface $storeManager
|
||||
* @param CollectionProcessorInterface $collectionProcessor
|
||||
* @param JoinProcessorInterface $extensionAttributesJoinProcessor
|
||||
* @param ExtensibleDataObjectConverter $extensibleDataObjectConverter
|
||||
*/
|
||||
public function __construct(
|
||||
ResourceCarousel $resource,
|
||||
CarouselFactory $carouselFactory,
|
||||
CarouselInterfaceFactory $dataCarouselFactory,
|
||||
CarouselCollectionFactory $carouselCollectionFactory,
|
||||
CarouselSearchResultsInterfaceFactory $searchResultsFactory,
|
||||
DataObjectHelper $dataObjectHelper,
|
||||
DataObjectProcessor $dataObjectProcessor,
|
||||
StoreManagerInterface $storeManager,
|
||||
CollectionProcessorInterface $collectionProcessor,
|
||||
JoinProcessorInterface $extensionAttributesJoinProcessor,
|
||||
ExtensibleDataObjectConverter $extensibleDataObjectConverter
|
||||
) {
|
||||
$this->resource = $resource;
|
||||
$this->carouselFactory = $carouselFactory;
|
||||
$this->carouselCollectionFactory = $carouselCollectionFactory;
|
||||
$this->searchResultsFactory = $searchResultsFactory;
|
||||
$this->dataObjectHelper = $dataObjectHelper;
|
||||
$this->dataCarouselFactory = $dataCarouselFactory;
|
||||
$this->dataObjectProcessor = $dataObjectProcessor;
|
||||
$this->storeManager = $storeManager;
|
||||
$this->collectionProcessor = $collectionProcessor;
|
||||
$this->extensionAttributesJoinProcessor = $extensionAttributesJoinProcessor;
|
||||
$this->extensibleDataObjectConverter = $extensibleDataObjectConverter;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function save(
|
||||
CarouselInterface $carousel
|
||||
) {
|
||||
/* if (empty($carousel->getStoreId())) {
|
||||
$storeId = $this->storeManager->getStore()->getId();
|
||||
$carousel->setStoreId($storeId);
|
||||
} */
|
||||
|
||||
$carouselData = $this->extensibleDataObjectConverter->toNestedArray(
|
||||
$carousel,
|
||||
[],
|
||||
CarouselInterface::class
|
||||
);
|
||||
|
||||
$carouselModel = $this->carouselFactory->create()->setData($carouselData);
|
||||
|
||||
try {
|
||||
$this->resource->save($carouselModel);
|
||||
} catch (Exception $exception) {
|
||||
throw new CouldNotSaveException(__(
|
||||
'Could not save the carousel: %1',
|
||||
$exception->getMessage()
|
||||
));
|
||||
}
|
||||
return $carouselModel->getDataModel();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getList(
|
||||
SearchCriteriaInterface $criteria
|
||||
) {
|
||||
$collection = $this->carouselCollectionFactory->create();
|
||||
|
||||
$this->extensionAttributesJoinProcessor->process(
|
||||
$collection,
|
||||
CarouselInterface::class
|
||||
);
|
||||
|
||||
$this->collectionProcessor->process($criteria, $collection);
|
||||
|
||||
$searchResults = $this->searchResultsFactory->create();
|
||||
$searchResults->setSearchCriteria($criteria);
|
||||
|
||||
$items = [];
|
||||
foreach ($collection as $model) {
|
||||
$items[] = $model->getDataModel();
|
||||
}
|
||||
|
||||
$searchResults->setItems($items);
|
||||
$searchResults->setTotalCount($collection->getSize());
|
||||
return $searchResults;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function deleteById($carouselId)
|
||||
{
|
||||
return $this->delete($this->get($carouselId));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function delete(
|
||||
CarouselInterface $carousel
|
||||
) {
|
||||
try {
|
||||
$carouselModel = $this->carouselFactory->create();
|
||||
$this->resource->load($carouselModel, $carousel->getCarouselId());
|
||||
$this->resource->delete($carouselModel);
|
||||
} catch (Exception $exception) {
|
||||
throw new CouldNotDeleteException(__(
|
||||
'Could not delete the Carousel: %1',
|
||||
$exception->getMessage()
|
||||
));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get($carouselId)
|
||||
{
|
||||
$carousel = $this->carouselFactory->create();
|
||||
$this->resource->load($carousel, $carouselId);
|
||||
if (!$carousel->getId()) {
|
||||
throw new NoSuchEntityException(__('Carousel with id "%1" does not exist.', $carouselId));
|
||||
}
|
||||
return $carousel->getDataModel();
|
||||
}
|
||||
}
|
||||
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Olegnax\Carousel\Model\Data;
|
||||
|
||||
use Magento\Framework\Api\AbstractExtensibleObject;
|
||||
use Olegnax\Carousel\Api\Data\CarouselExtensionInterface;
|
||||
use Olegnax\Carousel\Api\Data\CarouselInterface;
|
||||
|
||||
|
||||
class Carousel extends AbstractExtensibleObject implements CarouselInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Get carousel_id
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCarouselId()
|
||||
{
|
||||
return $this->_get(self::CAROUSEL_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set carousel_id
|
||||
* @param string $carouselId
|
||||
* @return CarouselInterface
|
||||
*/
|
||||
public function setCarouselId($carouselId)
|
||||
{
|
||||
return $this->setData(self::CAROUSEL_ID, $carouselId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get title
|
||||
* @return string|null
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->_get(self::TITLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title
|
||||
* @param string $title
|
||||
* @return CarouselInterface
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
return $this->setData(self::TITLE, $title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve existing extension attributes object or create a new one.
|
||||
* @return CarouselExtensionInterface|null
|
||||
*/
|
||||
public function getExtensionAttributes()
|
||||
{
|
||||
return $this->_getExtensionAttributes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an extension attributes object.
|
||||
* @param CarouselExtensionInterface $extensionAttributes
|
||||
* @return $this
|
||||
*/
|
||||
public function setExtensionAttributes(
|
||||
CarouselExtensionInterface $extensionAttributes
|
||||
) {
|
||||
return $this->_setExtensionAttributes($extensionAttributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get identifier
|
||||
* @return string|null
|
||||
*/
|
||||
public function getIdentifier()
|
||||
{
|
||||
return $this->_get(self::IDENTIFIER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set identifier
|
||||
* @param string $identifier
|
||||
* @return CarouselInterface
|
||||
*/
|
||||
public function setIdentifier($identifier)
|
||||
{
|
||||
return $this->setData(self::IDENTIFIER, $identifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get creation_time
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCreationTime()
|
||||
{
|
||||
return $this->_get(self::CREATION_TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set creation_time
|
||||
* @param string $creationTime
|
||||
* @return CarouselInterface
|
||||
*/
|
||||
public function setCreationTime($creationTime)
|
||||
{
|
||||
return $this->setData(self::CREATION_TIME, $creationTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get update_time
|
||||
* @return string|null
|
||||
*/
|
||||
public function getUpdateTime()
|
||||
{
|
||||
return $this->_get(self::UPDATE_TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set update_time
|
||||
* @param string $updateTime
|
||||
* @return CarouselInterface
|
||||
*/
|
||||
public function setUpdateTime($updateTime)
|
||||
{
|
||||
return $this->setData(self::UPDATE_TIME, $updateTime);
|
||||
}
|
||||
}
|
||||
|
||||
+735
@@ -0,0 +1,735 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Olegnax\Carousel\Model\Data;
|
||||
|
||||
use Magento\Framework\Api\AbstractExtensibleObject;
|
||||
use Olegnax\Carousel\Api\Data\SlideExtensionInterface;
|
||||
use Olegnax\Carousel\Api\Data\SlideInterface;
|
||||
|
||||
|
||||
class Slide extends AbstractExtensibleObject implements SlideInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Get slide_id
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSlideId()
|
||||
{
|
||||
return $this->_get(self::SLIDE_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set slide_id
|
||||
* @param string $slideId
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setSlideId($slideId)
|
||||
{
|
||||
return $this->setData(self::SLIDE_ID, $slideId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get carousel
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCarousel()
|
||||
{
|
||||
return $this->_get(self::CAROUSEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set carousel
|
||||
* @param string $carousel
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setCarousel($carousel)
|
||||
{
|
||||
return $this->setData(self::CAROUSEL, $carousel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve existing extension attributes object or create a new one.
|
||||
* @return SlideExtensionInterface|null
|
||||
*/
|
||||
public function getExtensionAttributes()
|
||||
{
|
||||
return $this->_getExtensionAttributes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an extension attributes object.
|
||||
* @param SlideExtensionInterface $extensionAttributes
|
||||
* @return $this
|
||||
*/
|
||||
public function setExtensionAttributes(
|
||||
SlideExtensionInterface $extensionAttributes
|
||||
) {
|
||||
return $this->_setExtensionAttributes($extensionAttributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get store_id
|
||||
* @return string|null
|
||||
*/
|
||||
public function getStoreId()
|
||||
{
|
||||
return $this->_get(self::STORE_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set store_id
|
||||
* @param string $storeId
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setStoreId($storeId)
|
||||
{
|
||||
return $this->setData(self::STORE_ID, $storeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get slide_bg
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSlideBg()
|
||||
{
|
||||
return $this->_get(self::SLIDE_BG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set slide_bg
|
||||
* @param string $slide_bg
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setSlideBg($slide_bg)
|
||||
{
|
||||
return $this->setData(self::SLIDE_BG, $slide_bg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image
|
||||
* @return string|null
|
||||
*/
|
||||
public function getImage()
|
||||
{
|
||||
return $this->_get(self::IMAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set image
|
||||
* @param string $image
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setImage($image)
|
||||
{
|
||||
return $this->setData(self::IMAGE, $image);
|
||||
}
|
||||
/**
|
||||
* Get mobile_image
|
||||
* @return string|null
|
||||
*/
|
||||
public function getMobileImage()
|
||||
{
|
||||
return $this->_get(self::MOBILE_IMAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set mobile_image
|
||||
* @param string $mobile_image
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setMobileImage($mobile_image)
|
||||
{
|
||||
return $this->setData(self::MOBILE_IMAGE, $mobile_image);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get is_active
|
||||
* @return string|null
|
||||
*/
|
||||
public function getIsActive()
|
||||
{
|
||||
return $this->_get(self::IS_ACTIVE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set is_active
|
||||
* @param string $isActive
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setIsActive($isActive)
|
||||
{
|
||||
return $this->setData(self::IS_ACTIVE, $isActive);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sort_order
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSortOrder()
|
||||
{
|
||||
return $this->_get(self::SORT_ORDER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set sort_order
|
||||
* @param string $sortOrder
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setSortOrder($sortOrder)
|
||||
{
|
||||
return $this->setData(self::SORT_ORDER, $sortOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content
|
||||
* @return string|null
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
return $this->_get(self::CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set content
|
||||
* @param string $content
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
return $this->setData(self::CONTENT, $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content2
|
||||
* @return string|null
|
||||
*/
|
||||
public function getContent2()
|
||||
{
|
||||
return $this->_get(self::CONTENT2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set content2
|
||||
* @param string $content2
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setContent2($content2)
|
||||
{
|
||||
return $this->setData(self::CONTENT2, $content2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get creation_time
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCreationTime()
|
||||
{
|
||||
return $this->_get(self::CREATION_TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set creation_time
|
||||
* @param string $creationTime
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setCreationTime($creationTime)
|
||||
{
|
||||
return $this->setData(self::CREATION_TIME, $creationTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get update_time
|
||||
* @return string|null
|
||||
*/
|
||||
public function getUpdateTime()
|
||||
{
|
||||
return $this->_get(self::UPDATE_TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set update_time
|
||||
* @param string $updateTime
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setUpdateTime($updateTime)
|
||||
{
|
||||
return $this->setData(self::UPDATE_TIME, $updateTime);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get layout
|
||||
* @return string|null
|
||||
*/
|
||||
public function getLayout()
|
||||
{
|
||||
return $this->_get(self::LAYOUT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set layout
|
||||
* @param string $layout
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setLayout($layout)
|
||||
{
|
||||
return $this->setData(self::LAYOUT, $layout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get subtitle_color
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSubtitleColor()
|
||||
{
|
||||
return $this->_get(self::SUBTITLE_COLOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set subtitle_color
|
||||
* @param string $subtitle_color
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setSubtitleColor($subtitle_color)
|
||||
{
|
||||
return $this->setData(self::SUBTITLE_COLOR, $subtitle_color);
|
||||
}
|
||||
/**
|
||||
* Get title_color
|
||||
* @return string|null
|
||||
*/
|
||||
public function getTitleColor()
|
||||
{
|
||||
return $this->_get(self::TITLE_COLOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title_color
|
||||
* @param string $title_color
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setTitleColor($title_color)
|
||||
{
|
||||
return $this->setData(self::TITLE_COLOR, $title_color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get title_bg
|
||||
* @return string|null
|
||||
*/
|
||||
public function getTitleBg()
|
||||
{
|
||||
return $this->_get(self::TITLE_BG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title_bg
|
||||
* @param string $title_bg
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setTitleBg($title_bg)
|
||||
{
|
||||
return $this->setData(self::TITLE_BG, $title_bg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get button_color
|
||||
* @return string|null
|
||||
*/
|
||||
public function getButtonColor()
|
||||
{
|
||||
return $this->_get(self::BUTTON_COLOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set button_color
|
||||
* @param string $button_color
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setButtonColor($button_color)
|
||||
{
|
||||
return $this->setData(self::BUTTON_COLOR, $button_color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get button_bg
|
||||
* @return string|null
|
||||
*/
|
||||
public function getButtonBg()
|
||||
{
|
||||
return $this->_get(self::BUTTON_BG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set button_bg
|
||||
* @param string $button_bg
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setButtonBg($button_bg)
|
||||
{
|
||||
return $this->setData(self::BUTTON_BG, $button_bg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get button_color_hover
|
||||
* @return string|null
|
||||
*/
|
||||
public function getButtonColorHover()
|
||||
{
|
||||
return $this->_get(self::BUTTON_COLOR_HOVER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set button_color_hover
|
||||
* @param string $button_color_hover
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setButtonColorHover($button_color_hover)
|
||||
{
|
||||
return $this->setData(self::BUTTON_COLOR_HOVER, $button_color_hover);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get button_bg_hover
|
||||
* @return string|null
|
||||
*/
|
||||
public function getButtonBgHover()
|
||||
{
|
||||
return $this->_get(self::BUTTON_BG_HOVER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set button_bg_hover
|
||||
* @param string $button_bg_hover
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setButtonBgHover($button_bg_hover)
|
||||
{
|
||||
return $this->setData(self::BUTTON_BG_HOVER, $button_bg_hover);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get text_color
|
||||
* @return string|null
|
||||
*/
|
||||
public function getTextColor()
|
||||
{
|
||||
return $this->_get(self::TEXT_COLOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set text_color
|
||||
* @param string $text_color
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setTextColor($text_color)
|
||||
{
|
||||
return $this->setData(self::TEXT_COLOR, $text_color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get subtitle
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSubtitle()
|
||||
{
|
||||
return $this->_get(self::SUBTITLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set subtitle
|
||||
* @param string $subtitle
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setSubtitle($subtitle)
|
||||
{
|
||||
return $this->setData(self::SUBTITLE, $subtitle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get title
|
||||
* @return string|null
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->_get(self::TITLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title
|
||||
* @param string $title
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
return $this->setData(self::TITLE, $title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get link
|
||||
* @return string|null
|
||||
*/
|
||||
public function getLink()
|
||||
{
|
||||
return $this->_get(self::LINK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set link
|
||||
* @param string $link
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setLink($link)
|
||||
{
|
||||
return $this->setData(self::LINK, $link);
|
||||
}
|
||||
/**
|
||||
* Get button
|
||||
* @return string|null
|
||||
*/
|
||||
public function getButton()
|
||||
{
|
||||
return $this->_get(self::BUTTON);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set button
|
||||
* @param string $button
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setButton($button)
|
||||
{
|
||||
return $this->setData(self::BUTTON, $button);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get nav_title
|
||||
* @return string|null
|
||||
*/
|
||||
public function getNavTitle()
|
||||
{
|
||||
return $this->_get(self::NAV_TITLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set nav_title
|
||||
* @param string $nav_title
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setNavTitle($nav_title)
|
||||
{
|
||||
return $this->setData(self::NAV_TITLE, $nav_title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get title_size
|
||||
* @return string|null
|
||||
*/
|
||||
public function getTitleSize()
|
||||
{
|
||||
return $this->_get(self::TITLE_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title_size
|
||||
* @param string $title_size
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setTitleSize($title_size)
|
||||
{
|
||||
return $this->setData(self::TITLE_SIZE, $title_size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get button_style
|
||||
* @return string|null
|
||||
*/
|
||||
public function getButtonStyle()
|
||||
{
|
||||
return $this->_get(self::BUTTON_STYLE);
|
||||
}
|
||||
/**
|
||||
* Set button_style
|
||||
* @param string $button_style
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setButtonStyle($button_style)
|
||||
{
|
||||
return $this->setData(self::BUTTON_STYLE, $button_style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content_width
|
||||
* @return string|null
|
||||
*/
|
||||
public function getContentWidth()
|
||||
{
|
||||
return $this->_get(self::CONTENT_WIDTH);
|
||||
}
|
||||
/**
|
||||
* Set content_width
|
||||
* @param string $content_width
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setContentWidth($content_width)
|
||||
{
|
||||
return $this->setData(self::CONTENT_WIDTH, $content_width);
|
||||
}
|
||||
/**
|
||||
* Get content_wrappers
|
||||
* @return string|null
|
||||
*/
|
||||
public function getContentWrappers()
|
||||
{
|
||||
return $this->_get(self::CONTENT_WRAPPERS);
|
||||
}
|
||||
/**
|
||||
* Set content_wrappers
|
||||
* @param string $content_wrappers
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setContentWrappers($content_wrappers)
|
||||
{
|
||||
return $this->setData(self::CONTENT_WRAPPERS, $content_wrappers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom_class
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCustomClass()
|
||||
{
|
||||
return $this->_get(self::CUSTOM_CLASS);
|
||||
}
|
||||
/**
|
||||
* Set custom_class
|
||||
* @param string $custom_class
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setCustomClass($custom_class)
|
||||
{
|
||||
return $this->setData(self::CUSTOM_CLASS, $custom_class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content_only
|
||||
* @return string|null
|
||||
*/
|
||||
public function getContentOnly()
|
||||
{
|
||||
return $this->_get(self::CONTENT_ONLY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set content_only
|
||||
* @param string $content_only
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setContentOnly($content_only)
|
||||
{
|
||||
return $this->setData(self::CONTENT_ONLY, $content_only);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get mobile_align
|
||||
* @return string|null
|
||||
*/
|
||||
public function getMobileAlign()
|
||||
{
|
||||
return $this->_get(self::MOBILE_ALIGN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set mobile_align
|
||||
* @param string $mobile_align
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setMobileAlign($mobile_align)
|
||||
{
|
||||
return $this->setData(self::MOBILE_ALIGN, $mobile_align);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get margins
|
||||
* @return string|null
|
||||
*/
|
||||
public function getMargins()
|
||||
{
|
||||
return $this->_get(self::MARGINS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set margins
|
||||
* @param string $margins
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setMargins($margins)
|
||||
{
|
||||
return $this->setData(self::MARGINS, $margins);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get button_css
|
||||
* @return string|null
|
||||
*/
|
||||
public function getButtonCss()
|
||||
{
|
||||
return $this->_get(self::BUTTON_CSS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set button_css
|
||||
* @param string $button_css
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setButtonCss($button_css)
|
||||
{
|
||||
return $this->setData(self::BUTTON_CSS, $button_css);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get slide_link
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSlideLink()
|
||||
{
|
||||
return $this->_get(self::SLIDE_LINK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set slide_link
|
||||
* @param string $slide_link
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function setSlideLink($slide_link)
|
||||
{
|
||||
return $this->setData(self::SLIDE_LINK, $slide_link);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Olegnax\Carousel\Model\ResourceModel;
|
||||
|
||||
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Model\AbstractModel;
|
||||
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
|
||||
|
||||
class Carousel extends AbstractDb
|
||||
{
|
||||
|
||||
/**
|
||||
* Define resource model
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init('olegnax_carousel_carousel', 'carousel_id');
|
||||
}
|
||||
|
||||
protected function _beforeSave(AbstractModel $object)
|
||||
{
|
||||
$data = $object->getData('identifier');
|
||||
if (empty($data)) {
|
||||
$data = $object->getData('Title');
|
||||
}
|
||||
$data = str_replace(' ', '_', strtolower($data));
|
||||
$object->setData('identifier', $data);
|
||||
|
||||
if (!$this->getIsUniqueCarousel($object)) {
|
||||
throw new LocalizedException(
|
||||
__('A Carousel identifier with the same properties already exists.')
|
||||
);
|
||||
}
|
||||
|
||||
return parent::_beforeSave($object);
|
||||
}
|
||||
|
||||
private function getIsUniqueCarousel(AbstractModel $object)
|
||||
{
|
||||
$select = $this->getConnection()->select()
|
||||
->from(['cb' => $this->getMainTable()])
|
||||
->where('cb.identifier = ? ', $object->getData('identifier'));
|
||||
|
||||
if ($this->getConnection()->fetchRow($select)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Olegnax\Carousel\Model\ResourceModel\Carousel;
|
||||
|
||||
|
||||
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
|
||||
use Olegnax\Carousel\Model\ResourceModel\Carousel;
|
||||
|
||||
class Collection extends AbstractCollection
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_idFieldName = 'carousel_id';
|
||||
|
||||
/**
|
||||
* Define resource model
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init(
|
||||
\Olegnax\Carousel\Model\Carousel::class,
|
||||
Carousel::class
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+201
@@ -0,0 +1,201 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Olegnax\Carousel\Model\ResourceModel;
|
||||
|
||||
use Magento\Catalog\Model\ImageUploader;
|
||||
use Magento\Framework\App\Filesystem\DirectoryList;
|
||||
use Magento\Framework\App\ObjectManager;
|
||||
use Magento\Framework\File\Uploader;
|
||||
use Magento\Framework\Filesystem;
|
||||
use Magento\Framework\Model\AbstractModel;
|
||||
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
|
||||
use Magento\Framework\Model\ResourceModel\Db\Context;
|
||||
use Magento\Framework\Serialize\Serializer\Json;
|
||||
use Olegnax\Carousel\Api\Data\SlideInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Slide extends AbstractDb
|
||||
{
|
||||
/**
|
||||
* @var Json
|
||||
*/
|
||||
protected $json;
|
||||
/**
|
||||
* @var ImageUploader
|
||||
*/
|
||||
private $imageUploader;
|
||||
/**
|
||||
* @var Filesystem
|
||||
*/
|
||||
private $_filesystem;
|
||||
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Filesystem $filesystem,
|
||||
Json $json,
|
||||
LoggerInterface $logger,
|
||||
$connectionName = null
|
||||
) {
|
||||
$this->_filesystem = $filesystem;
|
||||
$this->json = $json;
|
||||
$this->_logger = $logger;
|
||||
parent::__construct($context, $connectionName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define resource model
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init('olegnax_carousel_slide', 'slide_id');
|
||||
}
|
||||
|
||||
protected function _beforeSave(AbstractModel $object)
|
||||
{
|
||||
$data = $object->getData('store_id');
|
||||
if (!empty($data)) {
|
||||
if (is_array($data)) {
|
||||
$data = implode(',', $data);
|
||||
$object->setData('store_id', $data);
|
||||
}
|
||||
} else {
|
||||
$object->setData('store_id', 0);
|
||||
}
|
||||
$this->beforeSaveImage($object, SlideInterface::IMAGE);
|
||||
$this->beforeSaveImage($object, SlideInterface::MOBILE_IMAGE);
|
||||
|
||||
return parent::_beforeSave($object);
|
||||
}
|
||||
|
||||
private function beforeSaveImage($object, $attributeName)
|
||||
{
|
||||
$value = $object->getData($attributeName);
|
||||
|
||||
if ($this->fileResidesOutsideCategoryDir($value)) {
|
||||
// use relative path for image attribute so we know it's outside of category dir when we fetch it
|
||||
// phpcs:ignore Magento2.Functions.DiscouragedFunction
|
||||
$value[0]['url'] = parse_url($value[0]['url'], PHP_URL_PATH);
|
||||
$value[0]['name'] = $value[0]['url'];
|
||||
}
|
||||
|
||||
if ($imageName = $this->getUploadedImageName($value)) {
|
||||
if (!$this->fileResidesOutsideCategoryDir($value)) {
|
||||
$imageName = $this->checkUniqueImageName($imageName);
|
||||
}
|
||||
$object->setData($attributeName, $imageName);
|
||||
} elseif (!is_string($value)) {
|
||||
$object->setData($attributeName, null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for file path resides outside of category media dir. The URL will be a path including pub/media if true
|
||||
*
|
||||
* @param array|null $value
|
||||
* @return bool
|
||||
*/
|
||||
private function fileResidesOutsideCategoryDir($value)
|
||||
{
|
||||
if (!is_array($value) || !isset($value[0]['url'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$fileUrl = ltrim((string)$value[0]['url'], '/');
|
||||
$baseMediaDir = $this->_filesystem->getUri(DirectoryList::MEDIA);
|
||||
|
||||
if (!$baseMediaDir) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return strpos($fileUrl, $baseMediaDir) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets image name from $value array.
|
||||
*
|
||||
* Will return empty string in a case when $value is not an array.
|
||||
*
|
||||
* @param array $value Attribute value
|
||||
* @return string
|
||||
*/
|
||||
private function getUploadedImageName($value)
|
||||
{
|
||||
if (is_array($value) && isset($value[0]['name'])) {
|
||||
return $value[0]['name'];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that image name exists in catalog/category directory and return new image name if it already exists.
|
||||
*
|
||||
* @param string $imageName
|
||||
* @return string
|
||||
*/
|
||||
private function checkUniqueImageName(string $imageName): string
|
||||
{
|
||||
$imageUploader = $this->getImageUploader();
|
||||
$mediaDirectory = $this->_filesystem->getDirectoryWrite(DirectoryList::MEDIA);
|
||||
$imageAbsolutePath = $mediaDirectory->getAbsolutePath(
|
||||
$imageUploader->getBasePath() . DIRECTORY_SEPARATOR . $imageName
|
||||
);
|
||||
|
||||
$imageName = Uploader::getNewFilename($imageAbsolutePath);
|
||||
|
||||
return $imageName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Instance of Category Image Uploader.
|
||||
*
|
||||
* @return ImageUploader
|
||||
*
|
||||
* @deprecated 101.0.0
|
||||
*/
|
||||
private function getImageUploader()
|
||||
{
|
||||
if ($this->imageUploader === null) {
|
||||
$this->imageUploader = ObjectManager::getInstance()
|
||||
->get(ImageUploader::class);
|
||||
}
|
||||
|
||||
return $this->imageUploader;
|
||||
}
|
||||
|
||||
protected function _afterLoad(AbstractModel $object)
|
||||
{
|
||||
$data = $object->getData('store_id');
|
||||
if (!empty($data) && !is_array($data)) {
|
||||
$data = explode(',', $data);
|
||||
$object->setData('store_id', $data);
|
||||
}
|
||||
return parent::_afterLoad($object);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Olegnax\Carousel\Model\ResourceModel\Slide;
|
||||
|
||||
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface;
|
||||
use Magento\Framework\Data\Collection\EntityFactoryInterface;
|
||||
use Magento\Framework\DB\Adapter\AdapterInterface;
|
||||
use Magento\Framework\Event\ManagerInterface;
|
||||
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
|
||||
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
|
||||
use Magento\Store\Api\Data\StoreInterface;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
use Olegnax\Carousel\Model\ResourceModel\Slide;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Collection extends AbstractCollection
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_idFieldName = 'slide_id';
|
||||
/**
|
||||
* @var StoreManagerInterface
|
||||
*/
|
||||
protected $_storeManager;
|
||||
private $_storeId;
|
||||
|
||||
public function __construct(
|
||||
EntityFactoryInterface $entityFactory,
|
||||
LoggerInterface $logger,
|
||||
FetchStrategyInterface $fetchStrategy,
|
||||
ManagerInterface $eventManager,
|
||||
StoreManagerInterface $storeManager,
|
||||
AdapterInterface $connection = null,
|
||||
AbstractDb $resource = null
|
||||
) {
|
||||
$this->_storeManager = $storeManager;
|
||||
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add store availability filter. Include availability product
|
||||
* for store website
|
||||
*
|
||||
* @param null|string|bool|int $store
|
||||
* @return \Olegnax\Carousel\Model\ResourceModel\Slide\Collection
|
||||
*/
|
||||
public function addStoreFilter($store = null)
|
||||
{
|
||||
if ($store === null) {
|
||||
$store = $this->getStoreId();
|
||||
}
|
||||
$store = $this->_storeManager->getStore($store);
|
||||
|
||||
$this->getSelect()->where("(`store_id` = 0 OR `store_id` LIKE '?,%' OR `store_id` = ? OR `store_id` LIKE '%,?' OR `store_id` LIKE '%,?,%')", $store->getId(), 'int');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return current store id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getStoreId()
|
||||
{
|
||||
if ($this->_storeId === null) {
|
||||
$this->setStoreId($this->_storeManager->getStore()->getId());
|
||||
}
|
||||
return $this->_storeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set store scope
|
||||
*
|
||||
* @param int|string|StoreInterface $storeId
|
||||
* @return $this
|
||||
*/
|
||||
public function setStoreId($storeId)
|
||||
{
|
||||
if ($storeId instanceof StoreInterface) {
|
||||
$storeId = $storeId->getId();
|
||||
}
|
||||
$this->_storeId = (int)$storeId;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define resource model
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init(
|
||||
\Olegnax\Carousel\Model\Slide::class,
|
||||
Slide::class
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Executable
+238
@@ -0,0 +1,238 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Olegnax\Carousel\Model;
|
||||
|
||||
use Magento\Catalog\Model\Category\FileInfo;
|
||||
use Magento\Cms\Model\Template\FilterProvider;
|
||||
use Magento\Framework\Api\DataObjectHelper;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Filesystem\DirectoryList;
|
||||
use Magento\Framework\Filter\Template;
|
||||
use Magento\Framework\Model\AbstractModel;
|
||||
use Magento\Framework\Model\Context;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Framework\UrlInterface;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
use Olegnax\Carousel\Api\Data\SlideInterface;
|
||||
use Olegnax\Carousel\Api\Data\SlideInterfaceFactory;
|
||||
use Olegnax\Carousel\Model\ResourceModel\Slide\Collection;
|
||||
|
||||
|
||||
class Slide extends AbstractModel
|
||||
{
|
||||
|
||||
const UPDATE_TIME = 'update_time';
|
||||
protected $slideDataFactory;
|
||||
|
||||
protected $_eventPrefix = 'olegnax_carousel_slide';
|
||||
protected $dataObjectHelper;
|
||||
/**
|
||||
* @var StoreManagerInterface
|
||||
*/
|
||||
protected $_storeManager;
|
||||
/**
|
||||
* @var DirectoryList
|
||||
*/
|
||||
protected $directoryList;
|
||||
/**
|
||||
* @var FilterProvider
|
||||
*/
|
||||
protected $filterProvider;
|
||||
|
||||
/**
|
||||
* Slide constructor.
|
||||
* @param Context $context
|
||||
* @param Registry $registry
|
||||
* @param SlideInterfaceFactory $slideDataFactory
|
||||
* @param DataObjectHelper $dataObjectHelper
|
||||
* @param ResourceModel\Slide $resource
|
||||
* @param Collection $resourceCollection
|
||||
* @param StoreManagerInterface $storeManager
|
||||
* @param DirectoryList $directoryList
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Registry $registry,
|
||||
SlideInterfaceFactory $slideDataFactory,
|
||||
DataObjectHelper $dataObjectHelper,
|
||||
ResourceModel\Slide $resource,
|
||||
Collection $resourceCollection,
|
||||
StoreManagerInterface $storeManager,
|
||||
DirectoryList $directoryList,
|
||||
FilterProvider $filterProvider,
|
||||
array $data = []
|
||||
) {
|
||||
$this->slideDataFactory = $slideDataFactory;
|
||||
$this->dataObjectHelper = $dataObjectHelper;
|
||||
$this->_storeManager = $storeManager;
|
||||
$this->directoryList = $directoryList;
|
||||
$this->filterProvider = $filterProvider;
|
||||
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve slide model with slide data
|
||||
* @return SlideInterface
|
||||
*/
|
||||
public function getDataModel()
|
||||
{
|
||||
$slideData = $this->getData();
|
||||
|
||||
$slideDataObject = $this->slideDataFactory->create();
|
||||
$this->dataObjectHelper->populateWithArray(
|
||||
$slideDataObject,
|
||||
$slideData,
|
||||
SlideInterface::class
|
||||
);
|
||||
|
||||
return $slideDataObject;
|
||||
}
|
||||
|
||||
public function getIdentities()
|
||||
{
|
||||
return [$this->_eventPrefix . '_' . $this->getId()];
|
||||
}
|
||||
|
||||
public function beforeSave()
|
||||
{
|
||||
if ($this->hasDataChanges()) {
|
||||
$this->setUpdateTime(date('Y-m-d H:i:s'));
|
||||
}
|
||||
|
||||
parent::beforeSave();
|
||||
}
|
||||
|
||||
public function setUpdateTime($updateTime)
|
||||
{
|
||||
return $this->setData(self::UPDATE_TIME, $updateTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns image url
|
||||
*
|
||||
* @param string $attributeCode
|
||||
* @return bool|string
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
public function getImageUrl($attributeCode = 'image')
|
||||
{
|
||||
$url = false;
|
||||
$image = $this->getData($attributeCode);
|
||||
if ($image) {
|
||||
if (is_string($image)) {
|
||||
$store = $this->_storeManager->getStore();
|
||||
$baseUrl = $store->getBaseUrl();
|
||||
$baseUrl = str_replace(parse_url($baseUrl, PHP_URL_PATH), '/', $baseUrl);
|
||||
$url = $baseUrl . ltrim($image, '/');
|
||||
} else {
|
||||
throw new LocalizedException(
|
||||
__('Something went wrong while getting the image url.')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
public function hasImage($fieldId = 'image')
|
||||
{
|
||||
return ((bool)$this->getData($fieldId) !== false && $this->existsImage($fieldId));
|
||||
}
|
||||
|
||||
public function existsImage($fieldId = 'image')
|
||||
{
|
||||
$fullPath = $this->getAbsoluteImagePath($fieldId);
|
||||
return $fullPath
|
||||
&& file_exists($fullPath)
|
||||
&& is_file($fullPath);
|
||||
}
|
||||
|
||||
public function getAbsoluteImagePath($fieldId = 'image')
|
||||
{
|
||||
return $this->getPrefixedPath(
|
||||
$this->getData($fieldId),
|
||||
$this->directoryList->getPath("media")
|
||||
);
|
||||
}
|
||||
|
||||
private function getPrefixedPath($path, $prefix = '')
|
||||
{
|
||||
$fullPath = '';
|
||||
if (!empty($path)) {
|
||||
$path = preg_replace('#^/pub#i', '', $path);
|
||||
$path = preg_replace('#^/media#i', '', $path);
|
||||
if (preg_match('#/$#', $prefix)) {
|
||||
$path = ltrim($path, '/');
|
||||
}
|
||||
$fullPath = $prefix . $path;
|
||||
}
|
||||
return $fullPath;
|
||||
}
|
||||
|
||||
public function getContent($store_id = null)
|
||||
{
|
||||
$content = $this->getData('content');
|
||||
if (empty($content)) {
|
||||
$content = '';
|
||||
}
|
||||
$content = trim($content);
|
||||
/** @var Template $filter */
|
||||
$filter = $this->filterProvider->getBlockFilter();
|
||||
if (!empty($store_id)) {
|
||||
$filter = $filter->setStoreId($store_id);
|
||||
}
|
||||
$content = $filter->filter($content);
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function getContent2($store_id = null)
|
||||
{
|
||||
$content = $this->getData('content2');
|
||||
if (empty($content)) {
|
||||
$content = '';
|
||||
}
|
||||
$content = trim($content);
|
||||
/** @var Template $filter */
|
||||
$filter = $this->filterProvider->getBlockFilter();
|
||||
if (!empty($store_id)) {
|
||||
$filter = $filter->setStoreId($store_id);
|
||||
}
|
||||
$content = $filter->filter($content);
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model construct that should be used for object initialization
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init(ResourceModel\Slide::class);
|
||||
}
|
||||
}
|
||||
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Olegnax\Carousel\Model\Slide;
|
||||
|
||||
use Magento\Catalog\Model\Category\FileInfo;
|
||||
use Magento\Framework\App\ObjectManager;
|
||||
use Magento\Framework\App\Request\DataPersistorInterface;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Ui\DataProvider\AbstractDataProvider;
|
||||
use Olegnax\Carousel\Api\Data\SlideInterface;
|
||||
use Olegnax\Carousel\Model\ResourceModel\Slide\CollectionFactory;
|
||||
use Olegnax\Carousel\Model\Slide;
|
||||
|
||||
|
||||
class DataProvider extends AbstractDataProvider
|
||||
{
|
||||
|
||||
protected $dataPersistor;
|
||||
|
||||
protected $collection;
|
||||
|
||||
protected $loadedData;
|
||||
protected $fileInfo;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $primaryFieldName
|
||||
* @param string $requestFieldName
|
||||
* @param CollectionFactory $collectionFactory
|
||||
* @param DataPersistorInterface $dataPersistor
|
||||
* @param array $meta
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
$name,
|
||||
$primaryFieldName,
|
||||
$requestFieldName,
|
||||
CollectionFactory $collectionFactory,
|
||||
DataPersistorInterface $dataPersistor,
|
||||
array $meta = [],
|
||||
array $data = []
|
||||
) {
|
||||
$this->collection = $collectionFactory->create();
|
||||
$this->dataPersistor = $dataPersistor;
|
||||
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
if (isset($this->loadedData)) {
|
||||
return $this->loadedData;
|
||||
}
|
||||
$items = $this->collection->getItems();
|
||||
foreach ($items as $model) {
|
||||
$data = $model->getData();
|
||||
$data = $this->convertValues($data, $model);
|
||||
$this->loadedData[$model->getId()] = $data;
|
||||
}
|
||||
$data = $this->dataPersistor->get('olegnax_carousel_slide');
|
||||
|
||||
if (!empty($data)) {
|
||||
$model = $this->collection->getNewEmptyItem();
|
||||
$model->setData($data);
|
||||
$this->loadedData[$model->getId()] = $model->getData();
|
||||
$this->dataPersistor->clear('olegnax_carousel_slide');
|
||||
}
|
||||
|
||||
return $this->loadedData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @param Slide $model
|
||||
* @return mixed
|
||||
*/
|
||||
protected function convertValues($data, $model)
|
||||
{
|
||||
$data = $this->convertImage($data, $model, SlideInterface::IMAGE);
|
||||
$data = $this->convertImage($data, $model, SlideInterface::MOBILE_IMAGE);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @param Slide $model
|
||||
* @param string $attributeCode
|
||||
* @return mixed
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
private function convertImage($data, $model, $attributeCode){
|
||||
if (isset($data[$attributeCode]) && !empty($data[$attributeCode])) {
|
||||
unset($data[$attributeCode]);
|
||||
$fileName = $model->getData($attributeCode);
|
||||
$fileInfo = $this->getFileInfo();
|
||||
if ($fileInfo->isExist($fileName)) {
|
||||
$stat = $fileInfo->getStat($fileName);
|
||||
$mime = $fileInfo->getMimeType($fileName);
|
||||
|
||||
// phpcs:ignore Magento2.Functions.DiscouragedFunction
|
||||
$data[$attributeCode][0]['name'] = basename($fileName);
|
||||
|
||||
if ($fileInfo->isBeginsWithMediaDirectoryPath($fileName)) {
|
||||
$data[$attributeCode][0]['url'] = $fileName;
|
||||
} else {
|
||||
$data[$attributeCode][0]['url'] = $model->getImageUrl($attributeCode);
|
||||
}
|
||||
|
||||
$data[$attributeCode][0]['size'] = isset($stat) ? $stat['size'] : 0;
|
||||
$data[$attributeCode][0]['type'] = $mime;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get FileInfo instance
|
||||
*
|
||||
* @return FileInfo
|
||||
*
|
||||
* @deprecated 102.0.0
|
||||
*/
|
||||
private function getFileInfo(): FileInfo
|
||||
{
|
||||
if ($this->fileInfo === null) {
|
||||
$this->fileInfo = ObjectManager::getInstance()->get(FileInfo::class);
|
||||
}
|
||||
return $this->fileInfo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\Carousel\Model\Slide\Source;
|
||||
|
||||
use Magento\Framework\Option\ArrayInterface;
|
||||
|
||||
class ButtonStyle implements ArrayInterface
|
||||
{
|
||||
|
||||
public function toOptionArray() {
|
||||
return [
|
||||
[
|
||||
'value' => '',
|
||||
'label' => __('Theme')
|
||||
],
|
||||
[
|
||||
'value' => 'simple',
|
||||
'label' => __('Simple')
|
||||
],
|
||||
[
|
||||
'value' => 'naked',
|
||||
'label' => __('Naked')
|
||||
],
|
||||
[
|
||||
'value' => 'outline',
|
||||
'label' => __('OutLine')
|
||||
],
|
||||
[
|
||||
'value' => 'underline',
|
||||
'label' => __('Underlined')
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Olegnax\Carousel\Model\Slide\Source;
|
||||
|
||||
use Magento\Framework\Data\Collection;
|
||||
use Magento\Framework\Option\ArrayInterface;
|
||||
use Olegnax\Carousel\Model\ResourceModel\Carousel\CollectionFactory;
|
||||
|
||||
class Carousel implements ArrayInterface
|
||||
{
|
||||
|
||||
protected $collection;
|
||||
|
||||
public function __construct(
|
||||
CollectionFactory $collection
|
||||
) {
|
||||
$this->collection = $collection->create()->addFieldToSelect('*')->setOrder('title', Collection::SORT_ORDER_ASC);
|
||||
}
|
||||
|
||||
public function toArray()
|
||||
{
|
||||
$array = [];
|
||||
foreach ($this->toOptionArray() as $item) {
|
||||
$array[$item['value']] = $item['label'];
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
public function toOptionArray()
|
||||
{
|
||||
|
||||
$options = [];
|
||||
foreach ($this->collection as $carousel) {
|
||||
$options[] = [
|
||||
'value' => $carousel->getIdentifier(),
|
||||
'label' => $carousel->getTitle()
|
||||
];
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\Carousel\Model\Slide\Source;
|
||||
|
||||
use Magento\Framework\Option\ArrayInterface;
|
||||
|
||||
class Layout implements ArrayInterface
|
||||
{
|
||||
|
||||
public function toOptionArray() {
|
||||
return [
|
||||
[
|
||||
'value' => 'left',
|
||||
'label' => __('Left')
|
||||
],
|
||||
[
|
||||
'value' => 'right',
|
||||
'label' => __('Right')
|
||||
],
|
||||
[
|
||||
'value' => 'center',
|
||||
'label' => __('Center')
|
||||
],
|
||||
[
|
||||
'value' => '2-col',
|
||||
'label' => __('2 Columns')
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\Carousel\Model\Slide\Source;
|
||||
|
||||
use Magento\Framework\Option\ArrayInterface;
|
||||
|
||||
class Margins implements ArrayInterface
|
||||
{
|
||||
|
||||
public function toOptionArray() {
|
||||
return [
|
||||
[
|
||||
'value' => 'normal',
|
||||
'label' => __('Normal')
|
||||
],
|
||||
[
|
||||
'value' => 'big',
|
||||
'label' => __('Big')
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\Carousel\Model\Slide\Source;
|
||||
|
||||
use Magento\Framework\Option\ArrayInterface;
|
||||
|
||||
class MobileAlign implements ArrayInterface
|
||||
{
|
||||
|
||||
public function toOptionArray() {
|
||||
return [
|
||||
[
|
||||
'value' => 'left',
|
||||
'label' => __('Left')
|
||||
],
|
||||
[
|
||||
'value' => 'right',
|
||||
'label' => __('Right')
|
||||
],
|
||||
[
|
||||
'value' => 'center',
|
||||
'label' => __('Center')
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\Carousel\Model\Slide\Source;
|
||||
|
||||
use Magento\Framework\Option\ArrayInterface;
|
||||
|
||||
class TitleSize implements ArrayInterface
|
||||
{
|
||||
|
||||
public function toOptionArray() {
|
||||
return [
|
||||
[
|
||||
'value' => '',
|
||||
'label' => __('Normal')
|
||||
],
|
||||
[
|
||||
'value' => 'big',
|
||||
'label' => __('Medium')
|
||||
],
|
||||
[
|
||||
'value' => 'huge',
|
||||
'label' => __('Big')
|
||||
],
|
||||
[
|
||||
'value' => 'huge-6vw',
|
||||
'label' => __('Huge')
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\Carousel\Model\Slide\Source;
|
||||
|
||||
use Magento\Framework\Option\ArrayInterface;
|
||||
|
||||
class Wrappers implements ArrayInterface
|
||||
{
|
||||
|
||||
public function toOptionArray() {
|
||||
return [
|
||||
[
|
||||
'value' => 'container',
|
||||
'label' => __('Container')
|
||||
],
|
||||
[
|
||||
'value' => 'no-container',
|
||||
'label' => __('No Container')
|
||||
],
|
||||
[
|
||||
'value' => 'raw',
|
||||
'label' => __('Raw')
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
+199
@@ -0,0 +1,199 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Olegnax\Carousel\Model;
|
||||
|
||||
use Exception;
|
||||
use Magento\Framework\Api\DataObjectHelper;
|
||||
use Magento\Framework\Api\ExtensibleDataObjectConverter;
|
||||
use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;
|
||||
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
|
||||
use Magento\Framework\Api\SearchCriteriaInterface;
|
||||
use Magento\Framework\Exception\CouldNotDeleteException;
|
||||
use Magento\Framework\Exception\CouldNotSaveException;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Framework\Reflection\DataObjectProcessor;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
use Olegnax\Carousel\Api\Data\SlideInterface;
|
||||
use Olegnax\Carousel\Api\Data\SlideInterfaceFactory;
|
||||
use Olegnax\Carousel\Api\Data\SlideSearchResultsInterfaceFactory;
|
||||
use Olegnax\Carousel\Api\SlideRepositoryInterface;
|
||||
use Olegnax\Carousel\Model\ResourceModel\Slide as ResourceSlide;
|
||||
use Olegnax\Carousel\Model\ResourceModel\Slide\CollectionFactory as SlideCollectionFactory;
|
||||
|
||||
|
||||
class SlideRepository implements SlideRepositoryInterface
|
||||
{
|
||||
|
||||
protected $extensionAttributesJoinProcessor;
|
||||
|
||||
protected $dataSlideFactory;
|
||||
|
||||
protected $searchResultsFactory;
|
||||
protected $dataObjectProcessor;
|
||||
protected $dataObjectHelper;
|
||||
protected $extensibleDataObjectConverter;
|
||||
protected $slideCollectionFactory;
|
||||
protected $resource;
|
||||
protected $slideFactory;
|
||||
private $storeManager;
|
||||
private $collectionProcessor;
|
||||
|
||||
/**
|
||||
* @param ResourceSlide $resource
|
||||
* @param SlideFactory $slideFactory
|
||||
* @param SlideInterfaceFactory $dataSlideFactory
|
||||
* @param SlideCollectionFactory $slideCollectionFactory
|
||||
* @param SlideSearchResultsInterfaceFactory $searchResultsFactory
|
||||
* @param DataObjectHelper $dataObjectHelper
|
||||
* @param DataObjectProcessor $dataObjectProcessor
|
||||
* @param StoreManagerInterface $storeManager
|
||||
* @param CollectionProcessorInterface $collectionProcessor
|
||||
* @param JoinProcessorInterface $extensionAttributesJoinProcessor
|
||||
* @param ExtensibleDataObjectConverter $extensibleDataObjectConverter
|
||||
*/
|
||||
public function __construct(
|
||||
ResourceSlide $resource,
|
||||
SlideFactory $slideFactory,
|
||||
SlideInterfaceFactory $dataSlideFactory,
|
||||
SlideCollectionFactory $slideCollectionFactory,
|
||||
SlideSearchResultsInterfaceFactory $searchResultsFactory,
|
||||
DataObjectHelper $dataObjectHelper,
|
||||
DataObjectProcessor $dataObjectProcessor,
|
||||
StoreManagerInterface $storeManager,
|
||||
CollectionProcessorInterface $collectionProcessor,
|
||||
JoinProcessorInterface $extensionAttributesJoinProcessor,
|
||||
ExtensibleDataObjectConverter $extensibleDataObjectConverter
|
||||
) {
|
||||
$this->resource = $resource;
|
||||
$this->slideFactory = $slideFactory;
|
||||
$this->slideCollectionFactory = $slideCollectionFactory;
|
||||
$this->searchResultsFactory = $searchResultsFactory;
|
||||
$this->dataObjectHelper = $dataObjectHelper;
|
||||
$this->dataSlideFactory = $dataSlideFactory;
|
||||
$this->dataObjectProcessor = $dataObjectProcessor;
|
||||
$this->storeManager = $storeManager;
|
||||
$this->collectionProcessor = $collectionProcessor;
|
||||
$this->extensionAttributesJoinProcessor = $extensionAttributesJoinProcessor;
|
||||
$this->extensibleDataObjectConverter = $extensibleDataObjectConverter;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function save(
|
||||
SlideInterface $slide
|
||||
) {
|
||||
/* if (empty($slide->getStoreId())) {
|
||||
$storeId = $this->storeManager->getStore()->getId();
|
||||
$slide->setStoreId($storeId);
|
||||
} */
|
||||
|
||||
$slideData = $this->extensibleDataObjectConverter->toNestedArray(
|
||||
$slide,
|
||||
[],
|
||||
SlideInterface::class
|
||||
);
|
||||
|
||||
$slideModel = $this->slideFactory->create()->setData($slideData);
|
||||
|
||||
try {
|
||||
$this->resource->save($slideModel);
|
||||
} catch (Exception $exception) {
|
||||
throw new CouldNotSaveException(__(
|
||||
'Could not save the slide: %1',
|
||||
$exception->getMessage()
|
||||
));
|
||||
}
|
||||
return $slideModel->getDataModel();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getList(
|
||||
SearchCriteriaInterface $criteria
|
||||
) {
|
||||
$collection = $this->slideCollectionFactory->create();
|
||||
|
||||
$this->extensionAttributesJoinProcessor->process(
|
||||
$collection,
|
||||
SlideInterface::class
|
||||
);
|
||||
|
||||
$this->collectionProcessor->process($criteria, $collection);
|
||||
|
||||
$searchResults = $this->searchResultsFactory->create();
|
||||
$searchResults->setSearchCriteria($criteria);
|
||||
|
||||
$items = [];
|
||||
foreach ($collection as $model) {
|
||||
$items[] = $model->getDataModel();
|
||||
}
|
||||
|
||||
$searchResults->setItems($items);
|
||||
$searchResults->setTotalCount($collection->getSize());
|
||||
return $searchResults;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function deleteById($slideId)
|
||||
{
|
||||
return $this->delete($this->get($slideId));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function delete(
|
||||
SlideInterface $slide
|
||||
) {
|
||||
try {
|
||||
$slideModel = $this->slideFactory->create();
|
||||
$this->resource->load($slideModel, $slide->getSlideId());
|
||||
$this->resource->delete($slideModel);
|
||||
} catch (Exception $exception) {
|
||||
throw new CouldNotDeleteException(__(
|
||||
'Could not delete the Slide: %1',
|
||||
$exception->getMessage()
|
||||
));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get($slideId)
|
||||
{
|
||||
$slide = $this->slideFactory->create();
|
||||
$this->resource->load($slide, $slideId);
|
||||
if (!$slide->getId()) {
|
||||
throw new NoSuchEntityException(__('Slide with id "%1" does not exist.', $slideId));
|
||||
}
|
||||
return $slide->getDataModel();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user