41 lines
977 B
PHP
Executable File
41 lines
977 B
PHP
Executable File
<?php
|
|
|
|
namespace IpSupply\ChatMessage\Controller\Api;
|
|
|
|
use Magento\Framework\App\Action\Context;
|
|
|
|
class CurrentCustomerInfo extends \Magento\Framework\App\Action\Action {
|
|
|
|
protected $customerSession;
|
|
protected $objectManager;
|
|
|
|
public function __construct(
|
|
Context $context,
|
|
)
|
|
{
|
|
$this->objectManager = \Magento\Framework\App\ObjectManager::getInstance();
|
|
$this->customerSession = $this->objectManager->get(\Magento\Customer\Model\Session::class);
|
|
|
|
parent::__construct($context);
|
|
}
|
|
|
|
|
|
|
|
public function execute()
|
|
{
|
|
if($this->customerSession->isLoggedIn()) {
|
|
$customer = $this->customerSession->getCustomer();
|
|
$response = array();
|
|
$response["email"] = $customer->getEmail();
|
|
$response["fullname"] = $customer->getName();
|
|
echo json_encode($response);
|
|
exit;
|
|
} else {
|
|
echo null;
|
|
exit;
|
|
}
|
|
|
|
}
|
|
|
|
}
|