Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
State.php
Go to the documentation of this file.
1 <?php
7 
11 class State extends \Magento\Framework\Model\AbstractModel implements \Magento\Framework\Mview\View\StateInterface
12 {
18  protected $_eventPrefix = 'mview_state';
19 
25  protected $_eventObject = 'mview_state';
26 
34  public function __construct(
35  \Magento\Framework\Model\Context $context,
36  \Magento\Framework\Registry $registry,
37  \Magento\Indexer\Model\ResourceModel\Mview\View\State $resource,
38  \Magento\Indexer\Model\ResourceModel\Mview\View\State\Collection $resourceCollection,
39  array $data = []
40  ) {
41  if (!isset($data['mode'])) {
42  $data['mode'] = self::MODE_DISABLED;
43  }
44  if (!isset($data['status'])) {
45  $data['status'] = self::STATUS_IDLE;
46  }
47  parent::__construct($context, $registry, $resource, $resourceCollection, $data);
48  }
49 
56  public function loadByView($viewId)
57  {
58  $this->load($viewId, 'view_id');
59  if (!$this->getId()) {
60  $this->setViewId($viewId);
61  }
62  return $this;
63  }
64 
70  public function beforeSave()
71  {
72  $this->setUpdated(time());
73  return parent::beforeSave();
74  }
75 
81  public function getViewId()
82  {
83  return $this->getData('view_id');
84  }
85 
91  public function getMode()
92  {
93  return $this->getData('mode');
94  }
95 
102  public function setMode($mode)
103  {
104  $this->setData('mode', $mode);
105  return $this;
106  }
107 
113  public function getStatus()
114  {
115  return $this->getData('status');
116  }
117 
124  public function setStatus($status)
125  {
126  $this->setData('status', $status);
127  return $this;
128  }
129 
135  public function getUpdated()
136  {
137  return $this->getData('updated');
138  }
139 
146  public function setUpdated($updated)
147  {
148  $this->setData('updated', $updated);
149  return $this;
150  }
151 
157  public function getVersionId()
158  {
159  return $this->getData('version_id');
160  }
161 
168  public function setVersionId($versionId)
169  {
170  $this->setData('version_id', $versionId);
171  return $this;
172  }
173 }
getData($key='', $index=null)
Definition: DataObject.php:119
$resource
Definition: bulk.php:12
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
Definition: grid.phtml:15
__construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Indexer\Model\ResourceModel\Mview\View\State $resource, \Magento\Indexer\Model\ResourceModel\Mview\View\State\Collection $resourceCollection, array $data=[])
Definition: State.php:34
$status
Definition: order_status.php:8