43 lines
1.4 KiB
PHP
Executable File
43 lines
1.4 KiB
PHP
Executable File
<?php
|
|
|
|
namespace IpSupply\ChatMessage\Block\Widget;
|
|
|
|
use Magento\Framework\View\Element\Template;
|
|
use Magento\Widget\Block\BlockInterface;
|
|
use Magento\Framework\View\Element\Template\Context;
|
|
use Magento\Framework\App\ObjectManager;
|
|
use Magento\Store\Model\StoreManagerInterface;
|
|
use Magento\Framework\UrlInterface;
|
|
use GuzzleHttp\Client;
|
|
use GuzzleHttp\Psr7\Request as GuzzRequest;
|
|
|
|
|
|
class ChatBlockControl extends Template implements BlockInterface {
|
|
protected $_objectManager;
|
|
protected $_storeManager;
|
|
|
|
public function __construct(StoreManagerInterface $_storeManager, Context $context, array $data = []) {
|
|
$this->_objectManager = ObjectManager::getInstance();
|
|
$this->_storeManager = $_storeManager;
|
|
parent::__construct($context, $data);
|
|
}
|
|
|
|
function getAssetUrl($asset) {
|
|
$assetRepository = $this->_objectManager->get('Magento\Framework\View\Asset\Repository');
|
|
return $assetRepository->createAsset($asset)->getUrl();
|
|
}
|
|
|
|
function getBaseUrl() {
|
|
$storeManager = $this->_objectManager->get('\Magento\Store\Model\StoreManagerInterface');
|
|
$baseUrl = $storeManager->getStore()->getBaseUrl();
|
|
return $baseUrl;
|
|
}
|
|
|
|
function getCustomerInfo() {
|
|
$customerSession = $this->_objectManager->create('Magento\Customer\Model\Session');
|
|
if ($customerSession->isLoggedIn()) {
|
|
return ["logged" => True];
|
|
}
|
|
return ["logged" => False];
|
|
}
|
|
} |