Created
July 13, 2018 15:03
Revisions
-
petemcw created this gist
Jul 13, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ <?php namespace Petemcw; use Magento\Customer\Model\Session; class Customer { /** * @var \Magento\Customer\Model\Session */ private $customerSession; /** * Constructor. * * Initialize class dependencies. * * @param \Magento\Customer\Model\Session $customerSession */ public function __construct( Session $customerSession ) { $this->customerSession = $customerSession; } /** * Returns current customer's logged in status. * * @return bool */ public function isCustomerLoggedIn() { return $this->customerSession->isLoggedIn(); } /** * Returns an array of current customer information. * * return array */ public function getCurrentCustomerData() { return [ 'id' => $this->customerSession->getCustomer()->getId(), 'name' => $this->customerSession->getCustomer()->getName(), 'email' => $this->customerSession->getCustomer()->getEmail(), ]; } }