public function testSetTemplateContext() { $template = 'themedir/template.phtml'; $context = new \Magento\Framework\DataObject(); $this->_validator->expects($this->once())->method('isValid')->with($template)->will($this->returnValue(true)); $this->_templateEngine->expects($this->once())->method('render')->with($context); $this->_block->setTemplateContext($context); $this->_block->fetchView($template); }
/** * Wrap template with the debugging hints in comments * * @param Template $subject * @param string $result * * @return string */ public function afterToHtml(Template $subject, $result) { if ($this->scopeConfig->getValue(self::XML_PATH_DEBUG_TEMPLATE_HINTS, ScopeInterface::SCOPE_STORE) && $this->appState->getMode() === State::MODE_DEVELOPER) { $name = $subject->getNameInLayout(); $template = $subject->getTemplateFile(); $class = get_class($subject); $result = "<!-- BEGIN {$name} using {$template} \n" . $class . '-->' . $result . "<!-- END {$name} using {$template} -->"; } return $result; }
public function testSetTemplateContext() { $directoryMock = $this->getMock('\\Magento\\Framework\\Filesystem\\Directory\\Read', array(), array(), '', false); $directoryMock->expects($this->any())->method('getRelativePath')->will($this->returnArgument(0)); $this->_filesystem->expects($this->once())->method('getDirectoryRead')->will($this->returnValue($directoryMock)); $this->_filesystem->expects($this->any())->method('getPath')->will($this->returnValue('themedir')); $directoryMock->expects($this->once())->method('isFile')->with('themedir/template.phtml')->will($this->returnValue(true)); $context = new \Magento\Framework\Object(); $this->_templateEngine->expects($this->once())->method('render')->with($context); $this->_block->setTemplateContext($context); $this->_block->fetchView('themedir/template.phtml'); }
/** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\CatalogInventory\Api\StockStateInterface $stockState * @param \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry * @param array $data */ public function __construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\Registry $registry, \Magento\CatalogInventory\Api\StockStateInterface $stockState, \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry, array $data = []) { $this->_coreRegistry = $registry; $this->stockState = $stockState; $this->stockRegistry = $stockRegistry; parent::__construct($context, $data); }
/** * Render block HTML * * @return string */ protected function _toHtml() { if (false != $this->getTemplate()) { return parent::_toHtml(); } return '<li><a ' . $this->getLinkAttributes() . ' >' . $this->escapeHtml($this->getLabel()) . '</a></li>'; }
/** * Initialize dependencies * * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Store\Model\StoreFactory $storeFactory * @param \Magento\Framework\Registry $coreRegistry * @param \Magento\Tax\Service\V1\TaxRateServiceInterface $taxRateService * @param array $data */ public function __construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Store\Model\StoreFactory $storeFactory, \Magento\Framework\Registry $coreRegistry, \Magento\Tax\Service\V1\TaxRateServiceInterface $taxRateService, array $data = array()) { $this->_coreRegistry = $coreRegistry; $this->_taxRateService = $taxRateService; $this->_storeFactory = $storeFactory; parent::__construct($context, $data); }
/** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Framework\Filter\Input\MaliciousCode $maliciousCode * @param PriceCurrencyInterface $priceCurrency * @param \Magento\Catalog\Helper\Image $imageHelper * @param array $data */ public function __construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\Filter\Input\MaliciousCode $maliciousCode, PriceCurrencyInterface $priceCurrency, \Magento\Catalog\Helper\Image $imageHelper, array $data = []) { $this->imageHelper = $imageHelper; $this->priceCurrency = $priceCurrency; $this->_maliciousCode = $maliciousCode; parent::__construct($context, $data); }
/** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Wishlist\Helper\Data $wishlistHelper * @param \Magento\Framework\App\Rss\UrlBuilderInterface $rssUrlBuilder * @param \Magento\Framework\Url\EncoderInterface $urlEncoder * @param array $data */ public function __construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Wishlist\Helper\Data $wishlistHelper, \Magento\Framework\App\Rss\UrlBuilderInterface $rssUrlBuilder, \Magento\Framework\Url\EncoderInterface $urlEncoder, array $data = []) { parent::__construct($context, $data); $this->wishlistHelper = $wishlistHelper; $this->rssUrlBuilder = $rssUrlBuilder; $this->urlEncoder = $urlEncoder; }
/** * Render tag manager script * * @return string */ protected function _toHtml() { if ($this->_cookieHelper->isUserNotAllowSaveCookie() || !$this->_gtmHelper->isEnabled()) { return ''; } return parent::_toHtml(); }
/** * Render tag manager JS * * @return string */ protected function _toHtml() { if (!$this->_gtmHelper->isEnabled()) { return ''; } return parent::_toHtml(); }
protected function _construct() { parent::_construct(); // CSRF protection $this->_customerSession->setFacebookCsrf($csrf = md5(uniqid(rand(), true))); $this->_clientFacebook->setState($csrf); }
/** * PHP Constructor * * @param \Magento\Framework\View\Element\Template\Context $context App context * @param \Magento\Framework\Json\Helper\Data $jsonHelper The Magento's JSON Helper * @param \Smile\ElasticsuiteTracker\Helper\Data $trackerHelper The Smile Tracker helper * @param \Magento\Framework\Registry $registry The Magento registry * @param array $data additional datas */ public function __construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\Json\Helper\Data $jsonHelper, \Smile\ElasticsuiteTracker\Helper\Data $trackerHelper, \Magento\Framework\Registry $registry, array $data = []) { parent::__construct($context, $data); $this->jsonHelper = $jsonHelper; $this->trackerHelper = $trackerHelper; $this->registry = $registry; }
/** * @return string */ protected function _toHtml() { $cssClasses = $this->hasData('css_classes') ? explode(' ', $this->getData('css_classes')) : []; $cssClasses[] = 'price-' . $this->getPrice()->getPriceCode(); $this->setData('css_classes', implode(' ', $cssClasses)); return parent::_toHtml(); }
/** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param array $data * @codeCoverageIgnore */ public function __construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Catalog\Model\Session $catalogSession, \Magento\Checkout\Model\Session $checkoutSession, array $data = []) { $this->_orderFactory = $orderFactory; $this->_catalogSession = $catalogSession; $this->_checkoutSession = $checkoutSession; parent::__construct($context, $data); }
/** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Customer\Helper\Address $addressHelper * @param CustomerMetadataInterface $customerMetadata * @param array $data */ public function __construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Customer\Helper\Address $addressHelper, CustomerMetadataInterface $customerMetadata, array $data = []) { $this->_addressHelper = $addressHelper; $this->customerMetadata = $customerMetadata; parent::__construct($context, $data); $this->_isScopePrivate = true; }
public function _construct() { if (!$this->hasData('template')) { $this->setData('template', self::DEFAULT_REVIEW_TEMPLATE); } return parent::_construct(); }
/** * {@inheritdoc} * @param Context $context * @param QueryHelper $queryHelper * @param TextHelper $textHelper * @param UrlFactory $urlFactory */ public function __construct(Context $context, QueryHelper $queryHelper, TextHelper $textHelper, UrlFactory $urlFactory) { $this->query = $queryHelper; $this->urlFactory = $urlFactory; $this->text = $textHelper; parent::__construct($context); }
/** * Add payment info block to layout * * @return $this */ protected function _prepareLayout() { if ($info = $this->getPaymentInfo()) { $this->setChild($this->_getInfoBlockName(), $this->_paymentData->getInfoBlock($info, $this->getLayout())); } return parent::_prepareLayout(); }
public function __construct(\Dotdigitalgroup\Email\Helper\Data $helper, \Magento\Framework\ObjectManagerInterface $objectManagerInterface, \Magento\Backend\Block\Template\Context $context) { $data = []; $this->_helper = $helper; $this->_objectManager = $objectManagerInterface; parent::__construct($context, $data); }
/** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Checkout\Model\Session $checkoutSession * @param array $data */ public function __construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Customer\Model\Session $customerSession, \Magento\Checkout\Model\Session $checkoutSession, array $data = []) { $this->_customerSession = $customerSession; $this->_checkoutSession = $checkoutSession; parent::__construct($context, $data); $this->_isScopePrivate = true; }
/** * @return void */ protected function _construct() { $this->_loadData(); $this->setStores([]); $this->setLanguages([]); return parent::_construct(); }
/** * @return string */ public function _toHtml() { if (!$this->helper->isMultishippingCheckoutAvailable()) { return ''; } return parent::_toHtml(); }
/** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Wishlist\Helper\Data $wishlistData * @param \Magento\Wishlist\Model\Config $wishlistConfig * @param array $data */ public function __construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Wishlist\Helper\Data $wishlistData, \Magento\Wishlist\Model\Config $wishlistConfig, array $data = []) { $this->_wishlistData = $wishlistData; $this->_wishlistConfig = $wishlistConfig; parent::__construct($context, $data); $this->_isScopePrivate = true; }
/** * @param \Training\Test\Block\Context $context * @param \Magento\Framework\UrlFactory $urlFactory */ public function __construct(\Training\Test\Block\Context $context) { $this->_devToolHelper = $context->getTestHelper(); $this->_config = $context->getConfig(); $this->_urlApp = $context->getUrlFactory()->create(); parent::__construct($context); }
/** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Catalog\Helper\Category $categoryHelper * @param array $data */ public function __construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Catalog\Helper\Category $categoryHelper, \Magento\Catalog\Model\Indexer\Category\Flat\State $categoryFlatState, \Magento\Theme\Block\Html\Topmenu $topMenu) { $this->_categoryHelper = $categoryHelper; $this->categoryFlatConfig = $categoryFlatState; $this->topMenu = $topMenu; parent::__construct($context); }
/** * Constructor * * @param TemplateContext $context * @param UiComponentInterface $component * @param BlockFactory $blockWrapperFactory * @param array $data */ public function __construct(TemplateContext $context, UiComponentInterface $component, BlockFactory $blockWrapperFactory, array $data = []) { $this->component = $component; $this->blockWrapperFactory = $blockWrapperFactory; $this->setNameInLayout($this->component->getName()); parent::__construct($context, $data); }
/** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Http\Context $httpContext * @param array $data */ public function __construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Http\Context $httpContext, array $data = []) { $this->_coreRegistry = $registry; $this->httpContext = $httpContext; parent::__construct($context, $data); $this->_isScopePrivate = true; }
/** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory $setColFactory * @param \Magento\Framework\Registry $registry * @param \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper * @param array $data */ public function __construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory $setColFactory, \Magento\Framework\Registry $registry, \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper, array $data = []) { $this->_setColFactory = $setColFactory; $this->_coreRegistry = $registry; $this->_resourceHelper = $resourceHelper; parent::__construct($context, $data); }
/** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\ProductAlert\Helper\Data $helper * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Data\Helper\PostHelper $coreHelper * @param array $data */ public function __construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\ProductAlert\Helper\Data $helper, \Magento\Framework\Registry $registry, \Magento\Framework\Data\Helper\PostHelper $coreHelper, array $data = []) { parent::__construct($context, $data); $this->_registry = $registry; $this->_helper = $helper; $this->coreHelper = $coreHelper; }
/** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Review\Model\Resource\Review\CollectionFactory $collectionFactory * @param array $data */ public function __construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\Registry $registry, \Magento\Review\Model\Resource\Review\CollectionFactory $collectionFactory, array $data = []) { $this->_coreRegistry = $registry; $this->_reviewsColFactory = $collectionFactory; parent::__construct($context, $data); $this->setTabTitle(); }