Your IP : 127.0.0.1
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Framework\App\Helper;
/**
* Abstract helper
*
* @SuppressWarnings(PHPMD.NumberOfChildren)
*/
abstract class AbstractHelper
{
/**
* Helper module name
*
* @var string
*/
protected $_moduleName;
/**
* Request object
*
* @var \Magento\Framework\App\RequestInterface
*/
protected $_request;
/**
* @var \Magento\Framework\Module\Manager
*/
protected $_moduleManager;
/**
* @var \Psr\Log\LoggerInterface
*/
protected $_logger;
/**
* @var \Magento\Framework\UrlInterface
*/
protected $_urlBuilder;
/**
* @var \Magento\Framework\HTTP\Header
*/
protected $_httpHeader;
/**
* Event manager
*
* @var \Magento\Framework\Event\ManagerInterface
*/
protected $_eventManager;
/**
* @var \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress
*/
protected $_remoteAddress;
/**
* @var \Magento\Framework\Url\EncoderInterface
*/
protected $urlEncoder;
/**
* @var \Magento\Framework\Url\DecoderInterface
*/
protected $urlDecoder;
/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
protected $scopeConfig;
/**
* @var \Magento\Framework\Cache\ConfigInterface
*/
protected $_cacheConfig;
/**
* @param Context $context
*/
public function __construct(Context $context)
{
$this->_moduleManager = $context->getModuleManager();
$this->_logger = $context->getLogger();
$this->_request = $context->getRequest();
$this->_urlBuilder = $context->getUrlBuilder();
$this->_httpHeader = $context->getHttpHeader();
$this->_eventManager = $context->getEventManager();
$this->_remoteAddress = $context->getRemoteAddress();
$this->_cacheConfig = $context->getCacheConfig();
$this->urlEncoder = $context->getUrlEncoder();
$this->urlDecoder = $context->getUrlDecoder();
$this->scopeConfig = $context->getScopeConfig();
}
/**
* Retrieve request object
*
* @return \Magento\Framework\App\RequestInterface
*/
protected function _getRequest()
{
return $this->_request;
}
/**
* Retrieve helper module name
*
* @return string
*/
protected function _getModuleName()
{
if (!$this->_moduleName) {
$class = get_class($this);
$this->_moduleName = substr($class, 0, strpos($class, '\\Helper'));
}
return str_replace('\\', '_', $this->_moduleName);
}
/**
* Check whether or not the module output is enabled in Configuration
*
* @param string $moduleName Full module name
* @return boolean
* use \Magento\Framework\Module\Manager::isOutputEnabled()
*/
public function isModuleOutputEnabled($moduleName = null)
{
if ($moduleName === null) {
$moduleName = $this->_getModuleName();
}
return $this->_moduleManager->isOutputEnabled($moduleName);
}
/**
* Retrieve url
*
* @param string $route
* @param array $params
* @return string
*/
protected function _getUrl($route, $params = [])
{
return $this->_urlBuilder->getUrl($route, $params);
}
}