Created
February 10, 2018 17:31
-
-
Save kevinzie/3d8499e2e66a5063c3ca49ba35f368ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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