Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Cert.php
Go to the documentation of this file.
1 <?php
7 
12 {
16  protected $_coreDate;
17 
21  protected $dateTime;
22 
29  public function __construct(
30  \Magento\Framework\Model\ResourceModel\Db\Context $context,
31  \Magento\Framework\Stdlib\DateTime\DateTime $coreDate,
32  \Magento\Framework\Stdlib\DateTime $dateTime,
33  $connectionName = null
34  ) {
35  $this->_coreDate = $coreDate;
36  $this->dateTime = $dateTime;
37  parent::__construct($context, $connectionName);
38  }
39 
45  protected function _construct()
46  {
47  $this->_init('paypal_cert', 'cert_id');
48  }
49 
56  protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
57  {
58  $object->setUpdatedAt($this->dateTime->formatDate($this->_coreDate->gmtDate()));
59  return parent::_beforeSave($object);
60  }
61 
69  public function loadByWebsite($object, $strictLoad = true)
70  {
71  $connection = $this->getConnection();
72  $select = $connection->select()->from(['main_table' => $this->getMainTable()]);
73 
74  if ($strictLoad) {
75  $select->where('main_table.website_id =?', $object->getWebsiteId());
76  } else {
77  $select->where(
78  'main_table.website_id IN(0, ?)',
79  $object->getWebsiteId()
80  )->order(
81  'main_table.website_id DESC'
82  )->limit(
83  1
84  );
85  }
86 
87  $data = $connection->fetchRow($select);
88  if ($data) {
89  $object->setData($data);
90  }
91  return $object;
92  }
93 }
_beforeSave(\Magento\Framework\Model\AbstractModel $object)
Definition: Cert.php:56
__construct(\Magento\Framework\Model\ResourceModel\Db\Context $context, \Magento\Framework\Stdlib\DateTime\DateTime $coreDate, \Magento\Framework\Stdlib\DateTime $dateTime, $connectionName=null)
Definition: Cert.php:29
$connection
Definition: bulk.php:13
loadByWebsite($object, $strictLoad=true)
Definition: Cert.php:69