Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions
Nonce Class Reference
Inheritance diagram for Nonce:
AbstractDb AbstractResource

Public Member Functions

 deleteOldEntries ($minutes)
 
 selectByCompositeKey ($nonce, $consumerId)
 
- Public Member Functions inherited from AbstractDb
 __construct (\Magento\Framework\Model\ResourceModel\Db\Context $context, $connectionName=null)
 
 __sleep ()
 
 __wakeup ()
 
 getIdFieldName ()
 
 getMainTable ()
 
 getTable ($tableName)
 
 getConnection ()
 
 load (\Magento\Framework\Model\AbstractModel $object, $value, $field=null)
 
 save (\Magento\Framework\Model\AbstractModel $object)
 
 delete (\Magento\Framework\Model\AbstractModel $object)
 
 addUniqueField ($field)
 
 resetUniqueField ()
 
 unserializeFields (\Magento\Framework\Model\AbstractModel $object)
 
 getUniqueFields ()
 
 hasDataChanged ($object)
 
 getChecksum ($table)
 
 afterLoad (\Magento\Framework\DataObject $object)
 
 beforeSave (\Magento\Framework\DataObject $object)
 
 afterSave (\Magento\Framework\DataObject $object)
 
 beforeDelete (\Magento\Framework\DataObject $object)
 
 afterDelete (\Magento\Framework\DataObject $object)
 
 serializeFields (\Magento\Framework\Model\AbstractModel $object)
 
- Public Member Functions inherited from AbstractResource
 __construct ()
 
 getConnection ()
 
 beginTransaction ()
 
 addCommitCallback ($callback)
 
 commit ()
 
 rollBack ()
 
 getValidationRulesBeforeSave ()
 

Protected Member Functions

 _construct ()
 
- Protected Member Functions inherited from AbstractDb
 _init ($mainTable, $idFieldName)
 
 _setResource ($connections, $tables=null)
 
 _setMainTable ($mainTable, $idFieldName=null)
 
 _getConnection ($resourceName)
 
 _getLoadSelect ($field, $value, $object)
 
 _initUniqueFields ()
 
 _prepareDataForSave (\Magento\Framework\Model\AbstractModel $object)
 
 _prepareValueForSave ($value, $type)
 
 _checkUnique (\Magento\Framework\Model\AbstractModel $object)
 
 _afterLoad (\Magento\Framework\Model\AbstractModel $object)
 
 _beforeSave (\Magento\Framework\Model\AbstractModel $object)
 
 _afterSave (\Magento\Framework\Model\AbstractModel $object)
 
 _beforeDelete (\Magento\Framework\Model\AbstractModel $object)
 
 _afterDelete (\Magento\Framework\Model\AbstractModel $object)
 
 _serializeFields (\Magento\Framework\Model\AbstractModel $object)
 
 prepareDataForUpdate ($object)
 
 isObjectNotNew (\Magento\Framework\Model\AbstractModel $object)
 
 saveNewObject (\Magento\Framework\Model\AbstractModel $object)
 
 updateObject (\Magento\Framework\Model\AbstractModel $object)
 
 processAfterSaves (\Magento\Framework\Model\AbstractModel $object)
 
 isModified (\Magento\Framework\Model\AbstractModel $object)
 
 processNotModifiedSave (\Magento\Framework\Model\AbstractModel $object)
 
- Protected Member Functions inherited from AbstractResource
 _construct ()
 
 _serializeField (DataObject $object, $field, $defaultValue=null, $unsetEmpty=false)
 
 _unserializeField (DataObject $object, $field, $defaultValue=null)
 
 _prepareDataForTable (DataObject $object, $table)
 
 _prepareTableValueForSave ($value, $type)
 
 _getColumnsForEntityLoad (\Magento\Framework\Model\AbstractModel $object, $tableName)
 
 getSerializer ()
 

Additional Inherited Members

- Protected Attributes inherited from AbstractDb
 $_resources
 
 $connectionName = \Magento\Framework\App\ResourceConnection::DEFAULT_CONNECTION
 
 $_connections = []
 
 $_resourceModel
 
 $_tables = []
 
 $_mainTable
 
 $_idFieldName
 
 $_isPkAutoIncrement = true
 
 $_useIsObjectNew = false
 
 $_mainTableFields
 
 $_uniqueFields = null
 
 $_serializableFields = []
 
 $transactionManager
 
 $objectRelationProcessor
 
- Protected Attributes inherited from AbstractResource
 $serializer
 
 $_logger
 

Detailed Description

oAuth nonce resource model

Author
Magento Core Team core@.nosp@m.mage.nosp@m.ntoco.nosp@m.mmer.nosp@m.ce.co.nosp@m.m

Definition at line 13 of file Nonce.php.

Member Function Documentation

◆ _construct()

_construct ( )
protected

Initialize resource model

Returns
void

Definition at line 20 of file Nonce.php.

21  {
22  $this->_init('oauth_nonce', null);
23  }

◆ deleteOldEntries()

deleteOldEntries (   $minutes)

Delete old entries

Parameters
int$minutesDelete entries older than
Returns
int

Definition at line 31 of file Nonce.php.

32  {
33  if ($minutes > 0) {
34  $connection = $this->getConnection();
35 
36  return $connection->delete(
37  $this->getMainTable(),
38  $connection->quoteInto('timestamp <= ?', time() - $minutes * 60, \Zend_Db::INT_TYPE)
39  );
40  } else {
41  return 0;
42  }
43  }
const INT_TYPE
Definition: Db.php:68
$connection
Definition: bulk.php:13

◆ selectByCompositeKey()

selectByCompositeKey (   $nonce,
  $consumerId 
)

Select a unique nonce row using a composite primary key (i.e. $nonce and $consumerId)

Parameters
string$nonce- The nonce string
int$consumerId- The consumer id
Returns
array - Array of data

Definition at line 52 of file Nonce.php.

53  {
54  $connection = $this->getConnection();
55  $select = $connection->select()->from(
56  $this->getMainTable()
57  )->where(
58  'nonce = ?',
59  $nonce
60  )->where(
61  'consumer_id = ?',
62  $consumerId
63  );
64  $row = $connection->fetchRow($select);
65  return $row ? $row : [];
66  }
$connection
Definition: bulk.php:13

The documentation for this class was generated from the following file: