本文整理汇总了PHP中Magento\Framework\View\Result\Page::addPageLayoutHandles方法的典型用法代码示例。如果您正苦于以下问题:PHP Page::addPageLayoutHandles方法的具体用法?PHP Page::addPageLayoutHandles怎么用?PHP Page::addPageLayoutHandles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\View\Result\Page
的用法示例。
在下文中一共展示了Page::addPageLayoutHandles方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addPageLayoutHandles
/**
* {@inheritdoc}
*/
public function addPageLayoutHandles(array $parameters = array(), $defaultHandle = null)
{
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'addPageLayoutHandles');
if (!$pluginInfo) {
return parent::addPageLayoutHandles($parameters, $defaultHandle);
} else {
return $this->___callPlugins('addPageLayoutHandles', func_get_args(), $pluginInfo);
}
}
示例2: testAddPageLayoutHandlesWithDefaultHandle
public function testAddPageLayoutHandlesWithDefaultHandle()
{
$defaultHandle = 'default_handle';
$parameters = ['key_one' => 'val_one', 'key_two' => 'val_two'];
$expected = ['default_handle', 'default_handle_key_one_val_one', 'default_handle_key_two_val_two'];
$this->request->expects($this->never())->method('getFullActionName');
$this->layoutMerge->expects($this->any())->method('addHandle')->with($expected)->willReturnSelf();
$this->page->addPageLayoutHandles($parameters, $defaultHandle);
}
示例3: initProductLayout
/**
* Init layout for viewing product page
*
* @param \Magento\Framework\View\Result\Page $resultPage
* @param \Magento\Catalog\Model\Product $product
* @param null|\Magento\Framework\Object $params
* @return \Magento\Catalog\Helper\Product\View
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function initProductLayout(ResultPage $resultPage, $product, $params = null)
{
$settings = $this->_catalogDesign->getDesignSettings($product);
$pageConfig = $resultPage->getConfig();
if ($settings->getCustomDesign()) {
$this->_catalogDesign->applyCustomDesign($settings->getCustomDesign());
}
// Apply custom page layout
if ($settings->getPageLayout()) {
$pageConfig->setPageLayout($settings->getPageLayout());
}
$urlSafeSku = rawurlencode($product->getSku());
// Load default page handles and page configurations
if ($params && $params->getBeforeHandles()) {
foreach ($params->getBeforeHandles() as $handle) {
$resultPage->addPageLayoutHandles(['id' => $product->getId(), 'sku' => $urlSafeSku, 'type' => $product->getTypeId()], $handle);
}
}
$resultPage->addPageLayoutHandles(['id' => $product->getId(), 'sku' => $urlSafeSku, 'type' => $product->getTypeId()]);
if ($params && $params->getAfterHandles()) {
foreach ($params->getAfterHandles() as $handle) {
$resultPage->addPageLayoutHandles(['id' => $product->getId(), 'sku' => $urlSafeSku, 'type' => $product->getTypeId()], $handle);
}
}
// Apply custom layout update once layout is loaded
$update = $resultPage->getLayout()->getUpdate();
$layoutUpdates = $settings->getLayoutUpdates();
if ($layoutUpdates) {
if (is_array($layoutUpdates)) {
foreach ($layoutUpdates as $layoutUpdate) {
$update->addUpdate($layoutUpdate);
}
}
}
$currentCategory = $this->_coreRegistry->registry('current_category');
$controllerClass = $this->_request->getFullActionName();
if ($controllerClass != 'catalog-product-view') {
$pageConfig->addBodyClass('catalog-product-view');
}
$pageConfig->addBodyClass('product-' . $product->getUrlKey());
if ($currentCategory instanceof \Magento\Catalog\Model\Category) {
$pageConfig->addBodyClass('categorypath-' . $this->categoryUrlPathGenerator->getUrlPath($currentCategory))->addBodyClass('category-' . $currentCategory->getUrlKey());
}
return $this;
}
示例4: addPageLayoutHandles
/**
* Add layout updates handles associated with the action page
*
* @param array|null $parameters page parameters
* @param string|null $defaultHandle
* @return bool
*/
public function addPageLayoutHandles(array $parameters = [], $defaultHandle = null)
{
return $this->page->addPageLayoutHandles($parameters, $defaultHandle);
}