Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
AdminSessionInfo Class Reference
Inheritance diagram for AdminSessionInfo:
AbstractModel DataObject

Public Member Functions

 __construct (\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, ConfigInterface $securityConfig, \Magento\Framework\Stdlib\DateTime\DateTime $dateTime, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
 
 isLoggedInStatus ()
 
 isSessionExpired ()
 
 getFormattedIp ()
 
 isOtherSessionsTerminated ()
 
 setIsOtherSessionsTerminated ($isOtherSessionsTerminated)
 
- Public Member Functions inherited from AbstractModel
 __construct (\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
 
 __sleep ()
 
 __wakeup ()
 
 setIdFieldName ($name)
 
 getIdFieldName ()
 
 getId ()
 
 setId ($value)
 
 isDeleted ($isDeleted=null)
 
 hasDataChanges ()
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 setDataChanges ($value)
 
 getOrigData ($key=null)
 
 setOrigData ($key=null, $data=null)
 
 dataHasChangedFor ($field)
 
 getResourceName ()
 
 getResourceCollection ()
 
 getCollection ()
 
 load ($modelId, $field=null)
 
 beforeLoad ($identifier, $field=null)
 
 afterLoad ()
 
 isSaveAllowed ()
 
 setHasDataChanges ($flag)
 
 save ()
 
 afterCommitCallback ()
 
 isObjectNew ($flag=null)
 
 beforeSave ()
 
 validateBeforeSave ()
 
 getCacheTags ()
 
 cleanModelCache ()
 
 afterSave ()
 
 delete ()
 
 beforeDelete ()
 
 afterDelete ()
 
 afterDeleteCommit ()
 
 getResource ()
 
 getEntityId ()
 
 setEntityId ($entityId)
 
 clearInstance ()
 
 getStoredData ()
 
 getEventPrefix ()
 
- Public Member Functions inherited from DataObject
 __construct (array $data=[])
 
 addData (array $arr)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getData ($key='', $index=null)
 
 getDataByPath ($path)
 
 getDataByKey ($key)
 
 setDataUsingMethod ($key, $args=[])
 
 getDataUsingMethod ($key, $args=null)
 
 hasData ($key='')
 
 toArray (array $keys=[])
 
 convertToArray (array $keys=[])
 
 toXml (array $keys=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 convertToXml (array $arrAttributes=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 toJson (array $keys=[])
 
 convertToJson (array $keys=[])
 
 toString ($format='')
 
 __call ($method, $args)
 
 isEmpty ()
 
 serialize ($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"')
 
 debug ($data=null, &$objects=[])
 
 offsetSet ($offset, $value)
 
 offsetExists ($offset)
 
 offsetUnset ($offset)
 
 offsetGet ($offset)
 

Data Fields

const LOGGED_IN = 1
 
const LOGGED_OUT = 0
 
const LOGGED_OUT_BY_LOGIN = 2
 
const LOGGED_OUT_MANUALLY = 3
 

Protected Member Functions

 _construct ()
 
- Protected Member Functions inherited from AbstractModel
 _construct ()
 
 _init ($resourceModel)
 
 _setResourceModel ($resourceName, $collectionName=null)
 
 _getResource ()
 
 _getEventData ()
 
 _beforeLoad ($modelId, $field=null)
 
 _afterLoad ()
 
 _hasModelChanged ()
 
 _getValidatorBeforeSave ()
 
 _createValidatorBeforeSave ()
 
 _getValidationRulesBeforeSave ()
 
 _clearReferences ()
 
 _clearData ()
 
- Protected Member Functions inherited from DataObject
 _getData ($key)
 
 _underscore ($name)
 

Protected Attributes

 $isOtherSessionsTerminated = false
 
 $securityConfig
 
- Protected Attributes inherited from AbstractModel
 $_eventPrefix = 'core_abstract'
 
 $_eventObject = 'object'
 
 $_idFieldName = 'id'
 
 $_hasDataChanges = false
 
 $_origData
 
 $_isDeleted = false
 
 $_resource
 
 $_resourceCollection
 
 $_resourceName
 
 $_collectionName
 
 $_cacheTag = false
 
 $_dataSaveAllowed = true
 
 $_isObjectNew = null
 
 $_validatorBeforeSave = null
 
 $_eventManager
 
 $_cacheManager
 
 $_registry
 
 $_logger
 
 $_appState
 
 $_actionValidator
 
 $storedData = []
 
- Protected Attributes inherited from DataObject
 $_data = []
 

Additional Inherited Members

- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

Admin Session Info Model

@method string getSessionId() @method int getUserId() getUserId() @method int getStatus() @method string getUpdatedAt() @method string getCreatedAt()

@api

Since
100.1.0

Definition at line 20 of file AdminSessionInfo.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\Model\Context  $context,
\Magento\Framework\Registry  $registry,
ConfigInterface  $securityConfig,
\Magento\Framework\Stdlib\DateTime\DateTime  $dateTime,
\Magento\Framework\Model\ResourceModel\AbstractResource  $resource = null,
\Magento\Framework\Data\Collection\AbstractDb  $resourceCollection = null,
array  $data = [] 
)

AdminSessionInfo constructor

Parameters
\Magento\Framework\Model\Context$context
\Magento\Framework\Registry$registry
ConfigInterface$securityConfig
\Magento\Framework\Stdlib\DateTime\DateTime$dateTime
\Magento\Framework\Model\ResourceModel\AbstractResource | null$resource
\Magento\Framework\Data\Collection\AbstractDb | null$resourceCollection
array$data

Definition at line 74 of file AdminSessionInfo.php.

82  {
83  parent::__construct($context, $registry, $resource, $resourceCollection, $data);
84  $this->securityConfig = $securityConfig;
85  $this->dateTime = $dateTime;
86  }
$resource
Definition: bulk.php:12
$dateTime

Member Function Documentation

◆ _construct()

_construct ( )
protected

Initialize resource model

Returns
void
Since
100.1.0

Definition at line 94 of file AdminSessionInfo.php.

95  {
96  $this->_init(\Magento\Security\Model\ResourceModel\AdminSessionInfo::class);
97  }

◆ getFormattedIp()

getFormattedIp ( )

Get formatted IP

Returns
string
Since
100.1.0

Definition at line 147 of file AdminSessionInfo.php.

148  {
149  return $this->getIp();
150  }

◆ isLoggedInStatus()

isLoggedInStatus ( )

Check if a status is logged in

Returns
bool
Since
100.1.0

Definition at line 105 of file AdminSessionInfo.php.

106  {
107  $this->checkActivity();
108  return $this->getData('status') == self::LOGGED_IN;
109  }
getData($key='', $index=null)
Definition: DataObject.php:119

◆ isOtherSessionsTerminated()

isOtherSessionsTerminated ( )

Check if other sessions terminated

Returns
bool
Since
100.1.0

Definition at line 158 of file AdminSessionInfo.php.

◆ isSessionExpired()

isSessionExpired ( )

Check whether the session is expired

Returns
bool
Since
100.1.0

Definition at line 129 of file AdminSessionInfo.php.

130  {
131  $lifetime = $this->securityConfig->getAdminSessionLifetime();
132  $currentTime = $this->dateTime->gmtTimestamp();
133  $lastUpdatedTime = $this->getUpdatedAt();
134  if (!is_numeric($lastUpdatedTime)) {
135  $lastUpdatedTime = strtotime($lastUpdatedTime);
136  }
137 
138  return $lastUpdatedTime <= ($currentTime - $lifetime) ? true : false;
139  }

◆ setIsOtherSessionsTerminated()

setIsOtherSessionsTerminated (   $isOtherSessionsTerminated)

Setter for isOtherSessionsTerminated

Parameters
bool$isOtherSessionsTerminated
Returns
$this
Since
100.1.0

Definition at line 170 of file AdminSessionInfo.php.

Field Documentation

◆ $isOtherSessionsTerminated

All other open sessions were terminated

Since
100.1.0

Definition at line 50 of file AdminSessionInfo.php.

◆ $securityConfig

$securityConfig
protected

Definition at line 56 of file AdminSessionInfo.php.

◆ LOGGED_IN

const LOGGED_IN = 1

Admin session status definitionAdmin logged in

Definition at line 29 of file AdminSessionInfo.php.

◆ LOGGED_OUT

const LOGGED_OUT = 0

Admin logged out

Definition at line 34 of file AdminSessionInfo.php.

◆ LOGGED_OUT_BY_LOGIN

const LOGGED_OUT_BY_LOGIN = 2

User has been logged out by another login with the same credentials

Definition at line 39 of file AdminSessionInfo.php.

◆ LOGGED_OUT_MANUALLY

const LOGGED_OUT_MANUALLY = 3

User has been logged out manually from another session

Definition at line 44 of file AdminSessionInfo.php.


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