本文整理汇总了PHP中Magento\Framework\Event\Observer::getBlock方法的典型用法代码示例。如果您正苦于以下问题:PHP Observer::getBlock方法的具体用法?PHP Observer::getBlock怎么用?PHP Observer::getBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Event\Observer
的用法示例。
在下文中一共展示了Observer::getBlock方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* blocks , handles and template info is saved for current request
* via helpers
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
if (!$this->_devtoolData->getBlockStatus()) {
foreach ($observer->getBlock()->getLayout()->getAllBlocks() as $block) {
$this->_devtoolData->addBlockInfo($block->getNameInLayout(), get_class($block), $block->getTemplateFile());
}
$this->_devtoolData->setBlockStatus();
}
}
示例2: execute
public function execute(\Magento\Framework\Event\Observer $observer)
{
$grid = $observer->getBlock();
/**
* \Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Coupons\Grid
*/
if ($grid instanceof \Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Coupons\Grid) {
$grid->addColumnAfter('expiration_date', ['header' => __('Expiration date'), 'index' => 'expiration_date', 'type' => 'datetime', 'default' => '', 'align' => 'center', 'width' => '160'], 'created_at')->addColumnAfter('generated_by_dotmailer', ['header' => __('Generated By dotmailer'), 'index' => 'generated_by_dotmailer', 'type' => 'options', 'default' => '', 'options' => ['null' => 'No', '1' => 'Yes'], 'width' => '30', 'align' => 'center', 'filter_condition_callback' => [$this, 'filterCallbackContact']], 'expiration_date');
}
}
示例3: execute
/**
* Page block html topmenu gethtml before
*
* @param \Magento\Framework\Event\Observer $observer
* @return void
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
if (!$this->_scopeConfig->isSetFlag(static::XML_PATH_TOP_MENU_SHOW_ITEM, \Magento\Store\Model\ScopeInterface::SCOPE_STORE)) {
return;
}
/** @var \Magento\Framework\Data\Tree\Node $menu */
$menu = $observer->getMenu();
$block = $observer->getBlock();
$tree = $menu->getTree();
$data = ['name' => $this->_scopeConfig->getValue(static::XML_PATH_TOP_MENU_ITEM_TEXT, \Magento\Store\Model\ScopeInterface::SCOPE_STORE), 'id' => 'magefan-blog', 'url' => $this->_url->getBaseUrl(), 'is_active' => $block->getRequest()->getModuleName() == 'blog'];
$node = new Node($data, 'id', $tree, $menu);
$menu->addChild($node);
}
示例4: execute
/**
* @param mixed $observer
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @return void
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
$observer->getBlock()->setTemplate('Magento_ProductVideo::helper/gallery.phtml');
}
示例5: initOptionRenderer
/**
* Initialize product options renderer with downloadable specific params
*
* @param \Magento\Framework\Event\Observer $observer
* @return $this
*/
public function initOptionRenderer(\Magento\Framework\Event\Observer $observer)
{
$block = $observer->getBlock();
$block->addOptionsRenderCfg('downloadable', 'Magento\\Downloadable\\Helper\\Catalog\\Product\\Configuration');
return $this;
}
示例6: execute
/**
* Initialize product options renderer with bundle specific params
*
* @param \Magento\Framework\Event\Observer $observer
* @return $this
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
$block = $observer->getBlock();
$block->addOptionsRenderCfg('bundle', 'Magento\\Bundle\\Helper\\Catalog\\Product\\Configuration');
return $this;
}