magento2-docker/app/code/IpSupply/ChatMessage/Controller/Api/Register.php

38 lines
868 B
PHP
Executable File

<?php
namespace IpSupply\ChatMessage\Controller\Api;
use Magento\Framework\App\Action\Context;
class Register 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();
echo json_encode($customer->getEmail());
exit;
} else {
echo null;
exit;
}
}
}