Skip to content

Instantly share code, notes, and snippets.

@kevinzie
Created February 10, 2018 17:31
Show Gist options
  • Save kevinzie/3d8499e2e66a5063c3ca49ba35f368ab to your computer and use it in GitHub Desktop.
Save kevinzie/3d8499e2e66a5063c3ca49ba35f368ab to your computer and use it in GitHub Desktop.
<?php
namespace Vodex\Logger\Observer;
/**
* @category Logger
* @package Vodex_Logger
* @author [email protected]
* @website https://vodex.co.id
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
class MyObserver implements ObserverInterface
{
/**
* @var Data
*/
protected $authSession;
public function __construct(
...
\Magento\Backend\Model\Auth\Session $authSession
)
{
...
$this->authSession = $authSession;
...
}
public function getCurrentUser()
{
return $this->authSession->getUser();
}
public function execute(Observer $observer)
{
...
/**
* Get User Condition
* Check if User Logged In
*/
if ($this->authSession->isLoggedIn()) {
$userEmail = $this->authSession->getUser()->getEmail();
} else {
$userEmail = 'notloggedin';
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment