ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Olegnax Athlete Slideshow
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_AthleteSlideshow
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
|
||||
namespace Olegnax\Athlete2Slideshow\Model\Config\Source;
|
||||
|
||||
use Magento\Framework\Option\ArrayInterface;
|
||||
|
||||
class AutoHeight implements ArrayInterface
|
||||
{
|
||||
|
||||
public function toOptionArray()
|
||||
{
|
||||
return [['value' => 'container', 'label' => __('adjust height per slide')],['value' => 'calc', 'label' => __('calculate the tallest slide and use it')]];
|
||||
}
|
||||
|
||||
public function toArray()
|
||||
{
|
||||
return ['container' => __('adjust height per slide'),'calc' => __('calculate the tallest slide and use it')];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Olegnax Athlete Slideshow
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_AthleteSlideshow
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
|
||||
namespace Olegnax\Athlete2Slideshow\Model\Config\Source;
|
||||
|
||||
use Magento\Framework\Option\ArrayInterface;
|
||||
|
||||
class Easing implements ArrayInterface
|
||||
{
|
||||
|
||||
public function toOptionArray()
|
||||
{
|
||||
return [['value' => 'easeOutQuad', 'label' => __('easeOutQuad')],['value' => 'easeInQuad', 'label' => __('easeInQuad')],['value' => 'easeInOutQuad', 'label' => __('easeInOutQuad')],['value' => 'easeInCubic', 'label' => __('easeInCubic')],['value' => 'easeOutCubic', 'label' => __('easeOutCubic')],['value' => 'easeInOutCubic', 'label' => __('easeInOutCubic')],['value' => 'easeInQuart', 'label' => __('easeInQuart')],['value' => 'easeOutQuart', 'label' => __('easeOutQuart')],['value' => 'easeInOutQuart', 'label' => __('easeInOutQuart')],['value' => 'easeInQuint', 'label' => __('easeInQuint')],['value' => 'easeOutQuint', 'label' => __('easeOutQuint')],['value' => 'easeInOutQuint', 'label' => __('easeInOutQuint')],['value' => 'easeInSine', 'label' => __('easeInSine')],['value' => 'easeOutSine', 'label' => __('easeOutSine')],['value' => 'easeInOutSine', 'label' => __('easeInOutSine')],['value' => 'easeInExpo', 'label' => __('easeInExpo')],['value' => 'easeOutExpo', 'label' => __('easeOutExpo')],['value' => 'easeInOutExpo', 'label' => __('easeInOutExpo')],['value' => 'easeInCirc', 'label' => __('easeInCirc')],['value' => 'easeOutCirc', 'label' => __('easeOutCirc')],['value' => 'easeInOutCirc', 'label' => __('easeInOutCirc')],['value' => 'easeInElastic', 'label' => __('easeInElastic')],['value' => 'easeOutElastic', 'label' => __('easeOutElastic')],['value' => 'easeInOutElastic', 'label' => __('easeInOutElastic')],['value' => 'easeInBack', 'label' => __('easeInBack')],['value' => 'easeOutBack', 'label' => __('easeOutBack')],['value' => 'easeInOutBack', 'label' => __('easeInOutBack')],['value' => 'easeInBounce', 'label' => __('easeInBounce')],['value' => 'easeOutBounce', 'label' => __('easeOutBounce')],['value' => 'easeInOutBounce', 'label' => __('easeInOutBounce')]];
|
||||
}
|
||||
|
||||
public function toArray()
|
||||
{
|
||||
return ['easeOutQuad' => __('easeOutQuad'),'easeInQuad' => __('easeInQuad'),'easeInOutQuad' => __('easeInOutQuad'),'easeInCubic' => __('easeInCubic'),'easeOutCubic' => __('easeOutCubic'),'easeInOutCubic' => __('easeInOutCubic'),'easeInQuart' => __('easeInQuart'),'easeOutQuart' => __('easeOutQuart'),'easeInOutQuart' => __('easeInOutQuart'),'easeInQuint' => __('easeInQuint'),'easeOutQuint' => __('easeOutQuint'),'easeInOutQuint' => __('easeInOutQuint'),'easeInSine' => __('easeInSine'),'easeOutSine' => __('easeOutSine'),'easeInOutSine' => __('easeInOutSine'),'easeInExpo' => __('easeInExpo'),'easeOutExpo' => __('easeOutExpo'),'easeInOutExpo' => __('easeInOutExpo'),'easeInCirc' => __('easeInCirc'),'easeOutCirc' => __('easeOutCirc'),'easeInOutCirc' => __('easeInOutCirc'),'easeInElastic' => __('easeInElastic'),'easeOutElastic' => __('easeOutElastic'),'easeInOutElastic' => __('easeInOutElastic'),'easeInBack' => __('easeInBack'),'easeOutBack' => __('easeOutBack'),'easeInOutBack' => __('easeInOutBack'),'easeInBounce' => __('easeInBounce'),'easeOutBounce' => __('easeOutBounce'),'easeInOutBounce' => __('easeInOutBounce')];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Olegnax Athlete Slideshow
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_AthleteSlideshow
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
|
||||
namespace Olegnax\Athlete2Slideshow\Model\Config\Source;
|
||||
|
||||
use Magento\Framework\Option\ArrayInterface;
|
||||
|
||||
class Fx implements ArrayInterface
|
||||
{
|
||||
|
||||
public function toOptionArray()
|
||||
{
|
||||
return [['value' => 'scrollHorz', 'label' => __('scrollHorz')],['value' => 'scrollVert', 'label' => __('scrollVert')],['value' => 'fade', 'label' => __('fade')]];
|
||||
}
|
||||
|
||||
public function toArray()
|
||||
{
|
||||
return ['scrollHorz' => __('scrollHorz'),'scrollVert' => __('scrollVert'),'fade' => __('fade')];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Olegnax Athlete Slideshow
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_AthleteSlideshow
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
|
||||
namespace Olegnax\Athlete2Slideshow\Model\Config\Source;
|
||||
|
||||
use Magento\Framework\Option\ArrayInterface;
|
||||
|
||||
class Show implements ArrayInterface
|
||||
{
|
||||
|
||||
public function toOptionArray()
|
||||
{
|
||||
return [['value' => 'home', 'label' => __('HomePage Only')],['value' => 'all', 'label' => __('All Pages')]];
|
||||
}
|
||||
|
||||
public function toArray()
|
||||
{
|
||||
return ['home' => __('HomePage Only'),'all' => __('All Pages')];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Olegnax Athlete Slideshow
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_AthleteSlideshow
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
|
||||
namespace Olegnax\Athlete2Slideshow\Model\Config\Source;
|
||||
|
||||
use Magento\Framework\Option\ArrayInterface;
|
||||
|
||||
class Slider implements ArrayInterface
|
||||
{
|
||||
|
||||
public function toOptionArray()
|
||||
{
|
||||
return [['value' => 'athlete', 'label' => __('Athlete slider')],['value' => 'revolution', 'label' => __('Revolution Slides')]];
|
||||
}
|
||||
|
||||
public function toArray()
|
||||
{
|
||||
return ['athlete' => __('Athlete slider'),'revolution' => __('Revolution Slides')];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Olegnax Athlete Slideshow
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_AthleteSlideshow
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
|
||||
namespace Olegnax\Athlete2Slideshow\Model\Config\Source;
|
||||
|
||||
use Magento\Framework\App\ObjectManager;
|
||||
use Magento\Framework\Option\ArrayInterface;
|
||||
use Nwdthemes\Revslider\Model\ResourceModel\Slider\CollectionFactory;
|
||||
use Olegnax\Athlete2Slideshow\Helper\Helper;
|
||||
|
||||
class SliderId implements ArrayInterface {
|
||||
|
||||
/**
|
||||
*
|
||||
* @var CollectionFactory
|
||||
*/
|
||||
protected $revslider;
|
||||
/**
|
||||
*
|
||||
* @var ObjectManager
|
||||
*/
|
||||
public $_objectManager;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Helper
|
||||
*/
|
||||
public $_helper;
|
||||
|
||||
public function __construct( Helper $helper) {
|
||||
$this->_objectManager = ObjectManager::getInstance();
|
||||
$this->_helper = $helper;
|
||||
}
|
||||
|
||||
public function toOptionArray() {
|
||||
$options = [];
|
||||
if ($this->_helper->isRevoulutionModuleActive()) {
|
||||
if (!$this->revslider) {
|
||||
$this->revslider = $this->_objectManager->get('\Nwdthemes\Revslider\Model\ResourceModel\Slider\CollectionFactory')->create();
|
||||
}
|
||||
|
||||
if ($this->revslider && $this->revslider->getSize()) {
|
||||
$sliders = $this->revslider->addFieldToSelect('*')->setOrder('title', 'asc');
|
||||
foreach ($sliders as $slider) {
|
||||
$options[] = [
|
||||
'value' => $slider->getAlias(),
|
||||
'label' => $slider->getTitle()
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Olegnax Athlete Slideshow
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_AthleteSlideshow
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
|
||||
namespace Olegnax\Athlete2Slideshow\Model\ResourceModel;
|
||||
|
||||
use Magento\Framework\Model\AbstractModel;
|
||||
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
|
||||
|
||||
class Slides extends AbstractDb
|
||||
{
|
||||
|
||||
/**
|
||||
* Define resource model
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init('olegnax_athlete2slideshow_slides', 'id');
|
||||
}
|
||||
|
||||
protected function _beforeSave( AbstractModel $object) {
|
||||
$storeId = $object->getStoreId();
|
||||
if (is_array($storeId)) {
|
||||
$object->setStoreId(implode(',', $storeId));
|
||||
}
|
||||
|
||||
return parent::_beforeSave($object);
|
||||
}
|
||||
|
||||
protected function _afterLoad( AbstractModel $object) {
|
||||
$storeId = $object->getStoreId();
|
||||
if (!is_array($storeId)) {
|
||||
$storeId = explode(',', $storeId);
|
||||
$object->setStoreId($storeId);
|
||||
}
|
||||
|
||||
return parent::_afterLoad($object);
|
||||
}
|
||||
|
||||
}
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Olegnax Athlete Slideshow
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_AthleteSlideshow
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
|
||||
namespace Olegnax\Athlete2Slideshow\Model\ResourceModel\Slides;
|
||||
|
||||
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\Athlete2Slideshow\Model\ResourceModel\Slides;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Collection extends AbstractCollection {
|
||||
|
||||
/**
|
||||
* Current scope (store Id)
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_storeId;
|
||||
|
||||
/**
|
||||
* Store manager
|
||||
*
|
||||
* @var StoreManagerInterface
|
||||
*/
|
||||
protected $_storeManager;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define resource model
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct() {
|
||||
$this->_init(
|
||||
\Olegnax\Athlete2Slideshow\Model\Slides::class, Slides::class
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return current store id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getStoreId() {
|
||||
if ($this->_storeId === null) {
|
||||
$this->setStoreId($this->_storeManager->getStore()->getId());
|
||||
}
|
||||
return $this->_storeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add store availability filter. Include availability product
|
||||
* for store website
|
||||
*
|
||||
* @param null|string|bool|int $store
|
||||
* @return $this
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Olegnax Athlete Slideshow
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_AthleteSlideshow
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
namespace Olegnax\Athlete2Slideshow\Model;
|
||||
|
||||
use Magento\Framework\Filesystem\DirectoryList;
|
||||
use Magento\Framework\Filesystem\Io\File;
|
||||
use Magento\Framework\Model\AbstractModel;
|
||||
use Magento\Framework\Model\Context;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Framework\UrlInterface;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
|
||||
class Slides extends AbstractModel {
|
||||
|
||||
protected $directoryList;
|
||||
protected $io;
|
||||
protected $_storeManager;
|
||||
protected $_eventPrefix = 'olegnax_athlete2slideshow_slides';
|
||||
|
||||
public function __construct(
|
||||
Context $context, Registry $registry, StoreManagerInterface $storeManager, DirectoryList $directoryList, File $io
|
||||
) {
|
||||
$this->_storeManager = $storeManager;
|
||||
$this->directoryList = $directoryList;
|
||||
$this->io = $io;
|
||||
parent::__construct($context, $registry);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct() {
|
||||
$this->_init(\Olegnax\Athlete2Slideshow\Model\ResourceModel\Slides::class);
|
||||
}
|
||||
|
||||
public function getIdentities() {
|
||||
return [$this->_eventPrefix . '_' . $this->getId()];
|
||||
}
|
||||
|
||||
private function getPrefixedPath($path, $prefix = '') {
|
||||
$fullPath = '';
|
||||
$path = ltrim($path, '/');
|
||||
if (!empty($path)) {
|
||||
$fullPath = $prefix . $path;
|
||||
}
|
||||
|
||||
return $fullPath;
|
||||
}
|
||||
|
||||
public function getImageUrl($fieldId = 'image') {
|
||||
return $this->getPrefixedPath($this->getData($fieldId), rtrim((string)$this->_storeManager->getStore()->getBaseUrl( UrlInterface::URL_TYPE_MEDIA), '/') . '/');
|
||||
}
|
||||
|
||||
public function getImagePath($fieldId = 'image') {
|
||||
return $this->getPrefixedPath($this->getData($fieldId), $this->directoryList->getRoot() . '/pub/media/');
|
||||
}
|
||||
|
||||
public function existsImage($fieldId = 'image') {
|
||||
return is_file($this->getImagePath($fieldId));
|
||||
}
|
||||
|
||||
public function hasImage($fieldId = 'image') {
|
||||
|
||||
return ((bool) $this->getData($fieldId) !== false && $this->existsImage());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Olegnax Athlete Slideshow
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_AthleteSlideshow
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
|
||||
namespace Olegnax\Athlete2Slideshow\Model\Slides;
|
||||
|
||||
use Magento\Framework\App\Request\DataPersistorInterface;
|
||||
use Magento\Ui\DataProvider\AbstractDataProvider;
|
||||
use Olegnax\Athlete2Slideshow\Model\ResourceModel\Slides\CollectionFactory;
|
||||
|
||||
class DataProvider extends AbstractDataProvider
|
||||
{
|
||||
|
||||
protected $collection;
|
||||
|
||||
protected $dataPersistor;
|
||||
|
||||
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_athlete2slideshow_slides');
|
||||
|
||||
if (!empty($data)) {
|
||||
$model = $this->collection->getNewEmptyItem();
|
||||
$model->setData($data);
|
||||
$this->loadedData[$model->getId()] = $model->getData();
|
||||
$this->dataPersistor->clear('olegnax_athlete2slideshow_slides');
|
||||
}
|
||||
|
||||
return $this->loadedData;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user