本文整理汇总了PHP中Magento\Framework\View\Element\Template::_beforeToHtml方法的典型用法代码示例。如果您正苦于以下问题:PHP Template::_beforeToHtml方法的具体用法?PHP Template::_beforeToHtml怎么用?PHP Template::_beforeToHtml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\View\Element\Template
的用法示例。
在下文中一共展示了Template::_beforeToHtml方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _beforeToHtml
/**
* @return CheckoutSuccess
*/
protected function _beforeToHtml()
{
parent::_beforeToHtml();
if ($this->getInfo()->getMethod() === PaymentMethod::METHOD_CODE) {
$this->shouldOutput = true;
}
return $this;
}
示例2: _beforeToHtml
/**
* Initialize self totals and children blocks totals before html building
*
* @return $this
*/
protected function _beforeToHtml()
{
$this->_initTotals();
foreach ($this->getLayout()->getChildBlocks($this->getNameInLayout()) as $child) {
if (method_exists($child, 'initTotals') && is_callable([$child, 'initTotals'])) {
$child->initTotals();
}
}
return parent::_beforeToHtml();
}
示例3: _beforeToHtml
/**
* Prepare block text and determine whether block output enabled or not
* Prevent blocks recursion if needed
*
* @return $this
*/
protected function _beforeToHtml()
{
parent::_beforeToHtml();
$blockId = $this->getData('block_id');
$blockHash = get_class($this) . $blockId;
if (isset(self::$_widgetUsageMap[$blockHash])) {
return $this;
}
self::$_widgetUsageMap[$blockHash] = true;
if ($blockId) {
$storeId = $this->_storeManager->getStore()->getId();
/** @var \Magento\Cms\Model\Block $block */
$block = $this->_blockFactory->create();
$block->setStoreId($storeId)->load($blockId);
if ($block->isActive()) {
$this->setText($this->_filterProvider->getBlockFilter()->setStoreId($storeId)->filter($block->getContent()));
}
}
unset(self::$_widgetUsageMap[$blockHash]);
return $this;
}
示例4: _beforeToHtml
/**
* Prepare block text and determine whether block output enabled or not
* Prevent blocks recursion if needed
*
* @return $this
*/
protected function _beforeToHtml()
{
$store = $this->_storeManager->getStore()->getId();
if ($this->_scopeConfig->getValue(SliderModel::XMLSLIDERSTATUS, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store)) {
parent::_beforeToHtml();
$sliderId = $this->getSliderId();
if ($sliderId) {
$storeId = $this->_storeManager->getStore()->getId();
$slider = $this->_sliderFactory->create();
$sliderData = $slider->load($sliderId);
$sliderItemsData = $this->_slideritemsCollection->create()->addFieldToFilter('slideritem_slider', ['eq' => $sliderData->getId()])->addFieldToFilter('is_active', ['eq' => 1])->setOrder('slider_sort', 'desc');
$responsive = implode(",", $slider->getResponsiveWidth());
if ($sliderData->getSliderType() == 0) {
$sliderTemplate = new Fullwidth($this->_storeManager);
}
$sliderTemplate->setSliderResponsiveData($responsive);
$sliderTemplate->setSliderData($sliderData);
$sliderTemplate->setSlideritems($sliderItemsData);
if ($sliderData->getStatus()) {
$output = $sliderTemplate->renderSliderLayout();
$output .= '<div class="slidercontainer';
$output .= $sliderData->getSliderHidexs() ? ' hidden-xs' : '';
$output .= '">';
$output .= '<div class="slider_' . $sliderData->getID() . '">';
$output .= $sliderTemplate->renderSlider();
$output .= '</div></div>';
$output .= '
<script type="text/javascript">
require([\'jquery\',\'sz/tbslider\'], function($) {
});
</script>';
$this->setText($output);
}
}
return $this;
}
}
示例5: _beforeToHtml
/**
* @return \Magento\Framework\View\Element\AbstractBlock
*/
protected function _beforeToHtml()
{
$result = parent::_beforeToHtml();
$isInCatalog = $this->getIsInCatalogProduct();
if (!$this->_shortcutValidator->validate($this->_paymentMethodCode, $isInCatalog)) {
$this->_shouldRender = false;
return $result;
}
$quote = $isInCatalog || !$this->_checkoutSession ? null : $this->_checkoutSession->getQuote();
// set misc data
$this->setShortcutHtmlId($this->_mathRandom->getUniqueHash('ec_shortcut_'))->setCheckoutUrl($this->getUrl($this->_startAction));
// use static image if in catalog
if ($isInCatalog || null === $quote) {
$this->setImageUrl($this->config->getExpressCheckoutShortcutImageUrl($this->_localeResolver->getLocale()));
} else {
/**@todo refactor checkout model. Move getCheckoutShortcutImageUrl to helper or separate model */
$parameters = ['params' => ['quote' => $quote, 'config' => $this->config]];
$checkoutModel = $this->_checkoutFactory->create($this->_checkoutType, $parameters);
$this->setImageUrl($checkoutModel->getCheckoutShortcutImageUrl());
}
return $result;
}
示例6: _beforeToHtml
/**
* Initialize data and prepare it for output
*
* @return string
*/
protected function _beforeToHtml()
{
$this->_prepareLastOrder();
return parent::_beforeToHtml();
}
示例7: _beforeToHtml
/**
* Retrieve payment method and assign additional template values
*
* @return $this
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
*/
protected function _beforeToHtml()
{
$methodInstance = $this->_quote->getPayment()->getMethodInstance();
$this->setPaymentMethodTitle($methodInstance->getTitle());
$this->setShippingRateRequired(true);
if ($this->_quote->getIsVirtual()) {
$this->setShippingRateRequired(false);
} else {
// prepare shipping rates
$this->_address = $this->_quote->getShippingAddress();
$groups = $this->_address->getGroupedAllShippingRates();
if ($groups && $this->_address) {
$this->setShippingRateGroups($groups);
// determine current selected code & name
foreach ($groups as $code => $rates) {
foreach ($rates as $rate) {
if ($this->_address->getShippingMethod() == $rate->getCode()) {
$this->_currentShippingRate = $rate;
break 2;
}
}
}
}
$canEditShippingAddress = $this->_quote->getMayEditShippingAddress() && $this->_quote->getPayment()->getAdditionalInformation(\Magento\Paypal\Model\Express\Checkout::PAYMENT_INFO_BUTTON) == 1;
// misc shipping parameters
$this->setShippingMethodSubmitUrl($this->getUrl("{$this->_controllerPath}/saveShippingMethod"))->setCanEditShippingAddress($canEditShippingAddress)->setCanEditShippingMethod($this->_quote->getMayEditShippingMethod());
}
$this->setEditUrl($this->getUrl("{$this->_controllerPath}/edit"))->setPlaceOrderUrl($this->getUrl("{$this->_controllerPath}/placeOrder"));
return parent::_beforeToHtml();
}
示例8: _beforeToHtml
/**
* Initialize data and prepare it for output
*
* @return string
*/
protected function _beforeToHtml()
{
$this->prepareBlockData();
return parent::_beforeToHtml();
}
示例9: _beforeToHtml
/**
* Before rendering html, but after trying to load cache
*
* @return $this
*/
protected function _beforeToHtml()
{
$this->_prepareLastRecurringPayments();
return parent::_beforeToHtml();
}
示例10: _beforeToHtml
/**
* @return \Magento\Framework\View\Element\AbstractBlock
*/
protected function _beforeToHtml()
{
$result = parent::_beforeToHtml();
/** @var \Magento\Paypal\Model\Config $config */
$config = $this->_paypalConfigFactory->create();
$config->setMethod($this->_paymentMethodCode);
$isInCatalog = $this->getIsInCatalogProduct();
if (!$this->_shortcutValidator->validate($this->_paymentMethodCode, $isInCatalog)) {
$this->_shouldRender = false;
return $result;
}
$quote = $isInCatalog || !$this->_checkoutSession ? null : $this->_checkoutSession->getQuote();
// set misc data
$this->setShortcutHtmlId($this->_mathRandom->getUniqueHash('ec_shortcut_'))->setCheckoutUrl($this->getUrl($this->_startAction));
// use static image if in catalog
if ($isInCatalog || null === $quote) {
$this->setImageUrl($config->getExpressCheckoutShortcutImageUrl($this->_localeResolver->getLocale()));
} else {
/**@todo refactor checkout model. Move getCheckoutShortcutImageUrl to helper or separate model */
$parameters = ['params' => ['quote' => $quote, 'config' => $config]];
$checkoutModel = $this->_checkoutFactory->create($this->_checkoutType, $parameters);
$this->setImageUrl($checkoutModel->getCheckoutShortcutImageUrl());
}
// ask whether to create a billing agreement
$customerId = $this->currentCustomer->getCustomerId();
// potential issue for caching
if ($this->_paypalData->shouldAskToCreateBillingAgreement($config, $customerId)) {
$this->setConfirmationUrl($this->getUrl($this->_startAction, [\Magento\Paypal\Model\Express\Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT => 1]));
$this->setConfirmationMessage(__('Would you like to sign a billing agreement to streamline further purchases with PayPal?'));
}
return $result;
}
示例11: _beforeToHtml
/**
* Need use as _prepareLayout - but problem in declaring collection from
* another block (was problem with search result)
* @return $this
*/
protected function _beforeToHtml()
{
return parent::_beforeToHtml();
}
示例12: _beforeToHtml
/**
* Set back Url
*
* @return \Magento\RecurringPayment\Block\Payments
*/
protected function _beforeToHtml()
{
$this->setBackUrl($this->getUrl('customer/account/'));
return parent::_beforeToHtml();
}