Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Consumer.php
Go to the documentation of this file.
1 <?php
7 
9 {
14  public function __construct(
15  \Magento\Framework\Model\ResourceModel\Db\Context $context,
16  $connectionName = null
17  ) {
18  parent::__construct($context, $connectionName);
19  }
20 
26  protected function _construct()
27  {
28  $this->_init('oauth_consumer', 'entity_id');
29  }
30 
37  public function _afterDelete(\Magento\Framework\Model\AbstractModel $object)
38  {
39  $connection = $this->getConnection();
40  $connection->delete($this->getTable('oauth_nonce'), ['consumer_id = ?' => (int)$object->getId()]);
41  $connection->delete($this->getTable('oauth_token'), ['consumer_id = ?' => (int)$object->getId()]);
42  return parent::_afterDelete($object);
43  }
44 
53  public function getTimeInSecondsSinceCreation($consumerId)
54  {
55  $connection = $this->getConnection();
56  $select = $connection->select()
57  ->from($this->getMainTable())
58  ->reset(\Magento\Framework\DB\Select::COLUMNS)
59  ->columns(new \Zend_Db_Expr('CURRENT_TIMESTAMP() - created_at'))
60  ->where('entity_id = ?', $consumerId);
61 
62  return $connection->fetchOne($select);
63  }
64 }
__construct(\Magento\Framework\Model\ResourceModel\Db\Context $context, $connectionName=null)
Definition: Consumer.php:14
_afterDelete(\Magento\Framework\Model\AbstractModel $object)
Definition: Consumer.php:37
$connection
Definition: bulk.php:13