Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Activity.php
Go to the documentation of this file.
1 <?php
7 
10 
18 {
23  protected $securityConfig;
24 
29  protected $sessionsManager;
30 
36 
40  private $remoteAddress;
41 
48  public function __construct(
49  \Magento\Backend\Block\Template\Context $context,
51  \Magento\Security\Model\AdminSessionsManager $sessionsManager,
52  RemoteAddress $remoteAddress
53  ) {
54  parent::__construct($context);
55  $this->securityConfig = $securityConfig;
56  $this->sessionsManager = $sessionsManager;
57  $this->remoteAddress = $remoteAddress;
58  }
59 
64  public function getSessionInfoCollection()
65  {
66  if (null === $this->sessionsInfoCollection) {
67  $this->sessionsInfoCollection = $this->sessionsManager->getSessionsForCurrentUser();
68  }
70  }
71 
76  public function areMultipleSessionsActive()
77  {
78  return count($this->getSessionInfoCollection()) > 1;
79  }
80 
85  public function getRemoteIp()
86  {
87  return $this->remoteAddress->getRemoteAddress(false);
88  }
89 
97  public function formatDateTime($time)
98  {
99  $time = new \DateTime($time);
100  return $this->_localeDate->formatDateTime(
101  $time,
102  \IntlDateFormatter::MEDIUM,
103  \IntlDateFormatter::MEDIUM
104  );
105  }
106 }
__construct(\Magento\Backend\Block\Template\Context $context, ConfigInterface $securityConfig, \Magento\Security\Model\AdminSessionsManager $sessionsManager, RemoteAddress $remoteAddress)
Definition: Activity.php:48