magento2-docker/app/code/IpSupply/QuoteIn/Controller/ListDatas/Index.php

61 lines
1.5 KiB
PHP
Executable File

<?php
namespace IpSupply\QuoteIn\Controller\ListDatas;
use Magento\Framework\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;
use IpSupply\QuoteIn\Api\QuoteInApi;
use IpSupply\QuoteIn\Helper\LogHelper;
class Index extends \Magento\Framework\App\Action\Action {
const LOG_FILE = "ipsupply_quote_in.log";
protected $pageFactory;
protected $logHelper;
protected $quoteInApi;
public function __construct(
Context $context,
PageFactory $pageFactory,
LogHelper $logHelper,
QuoteInApi $quoteInApi,
)
{
$this->pageFactory = $pageFactory;
$this->logHelper = $logHelper;
$this->quoteInApi = $quoteInApi;
parent::__construct($context);
}
private function getCustomer(){
$om = \Magento\Framework\App\ObjectManager::getInstance();
$customerSession = $om->get('Magento\Customer\Model\Session');
$customer = $customerSession->getCustomer();
return $customer;
}
public function execute()
{
$customer = $this->getCustomer();
if (!$customer) {
echo "{}";
exit;
}
//$this->logHelper->setName(self::LOG_FILE);
//$this->quoteInApi->setLogHelper($this->logHelper);
$response = $this->quoteInApi->login();
if ($response) {
$rep = $this->quoteInApi->getData($customer->getEmail());
echo $rep->getBody()->getContents();
exit;
}
echo "null";
exit;
}
}