当前位置: 首页>>代码示例>>PHP>>正文


PHP View\LayoutFactory类代码示例

本文整理汇总了PHP中Magento\Framework\View\LayoutFactory的典型用法代码示例。如果您正苦于以下问题:PHP LayoutFactory类的具体用法?PHP LayoutFactory怎么用?PHP LayoutFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了LayoutFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Construct
  *
  * @param \Magento\Framework\App\Helper\Context $context
  * @param LayoutFactory $layoutFactory
  * @param \Magento\Payment\Model\Method\Factory $paymentMethodFactory
  * @param \Magento\Store\Model\App\Emulation $appEmulation
  * @param \Magento\Payment\Model\Config $paymentConfig
  * @param \Magento\Framework\App\Config\Initial $initialConfig
  */
 public function __construct(\Magento\Framework\App\Helper\Context $context, LayoutFactory $layoutFactory, \Magento\Payment\Model\Method\Factory $paymentMethodFactory, \Magento\Store\Model\App\Emulation $appEmulation, \Magento\Payment\Model\Config $paymentConfig, \Magento\Framework\App\Config\Initial $initialConfig)
 {
     parent::__construct($context);
     $this->_layout = $layoutFactory->create();
     $this->_methodFactory = $paymentMethodFactory;
     $this->_appEmulation = $appEmulation;
     $this->_paymentConfig = $paymentConfig;
     $this->_initialConfig = $initialConfig;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:19,代码来源:Data.php

示例2: __construct

 /**
  * Constructor
  *
  * @param View\Element\Template\Context $context
  * @param View\LayoutFactory $layoutFactory
  * @param View\Layout\ReaderPool $layoutReaderPool
  * @param Framework\Translate\InlineInterface $translateInline
  * @param View\Layout\BuilderFactory $layoutBuilderFactory
  * @param View\Layout\GeneratorPool $generatorPool
  * @param bool $isIsolated
  */
 public function __construct(View\Element\Template\Context $context, View\LayoutFactory $layoutFactory, View\Layout\ReaderPool $layoutReaderPool, Framework\Translate\InlineInterface $translateInline, View\Layout\BuilderFactory $layoutBuilderFactory, View\Layout\GeneratorPool $generatorPool, $isIsolated = false)
 {
     $this->layoutFactory = $layoutFactory;
     $this->layoutBuilderFactory = $layoutBuilderFactory;
     $this->layoutReaderPool = $layoutReaderPool;
     $this->eventManager = $context->getEventManager();
     $this->request = $context->getRequest();
     $this->translateInline = $translateInline;
     // TODO Shared layout object will be deleted in MAGETWO-28359
     $this->layout = $isIsolated ? $this->layoutFactory->create(['reader' => $this->layoutReaderPool, 'generatorPool' => $generatorPool]) : $context->getLayout();
     $this->layout->setGeneratorPool($generatorPool);
     $this->initLayoutBuilder();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:24,代码来源:Layout.php

示例3: executeInternal

 /**
  * Attributes validation action
  *
  * @return \Magento\Framework\Controller\ResultInterface
  */
 public function executeInternal()
 {
     $response = $this->_objectManager->create('Magento\\Framework\\DataObject');
     $response->setError(false);
     $attributesData = $this->getRequest()->getParam('attributes', []);
     $data = $this->_objectManager->create('Magento\\Catalog\\Model\\Product');
     try {
         if ($attributesData) {
             foreach ($attributesData as $attributeCode => $value) {
                 $attribute = $this->_objectManager->get('Magento\\Eav\\Model\\Config')->getAttribute('catalog_product', $attributeCode);
                 if (!$attribute->getAttributeId()) {
                     unset($attributesData[$attributeCode]);
                     continue;
                 }
                 $data->setData($attributeCode, $value);
                 $attribute->getBackend()->validate($data);
             }
         }
     } catch (\Magento\Eav\Model\Entity\Attribute\Exception $e) {
         $response->setError(true);
         $response->setAttribute($e->getAttributeCode());
         $response->setMessage($e->getMessage());
     } catch (\Magento\Framework\Exception\LocalizedException $e) {
         $response->setError(true);
         $response->setMessage($e->getMessage());
     } catch (\Exception $e) {
         $this->messageManager->addException($e, __('Something went wrong while updating the product(s) attributes.'));
         $layout = $this->layoutFactory->create();
         $layout->initMessages();
         $response->setError(true);
         $response->setHtmlMessage($layout->getMessagesBlock()->getGroupedHtml());
     }
     return $this->resultJsonFactory->create()->setJsonData($response->toJson());
 }
开发者ID:nblair,项目名称:magescotch,代码行数:39,代码来源:Validate.php

示例4: execute

 /**
  * @return \Magento\Framework\Controller\ResultInterface
  */
 public function execute()
 {
     $response = new \Magento\Framework\Object();
     $response->setError(false);
     $attributeCode = $this->getRequest()->getParam('attribute_code');
     $frontendLabel = $this->getRequest()->getParam('frontend_label');
     $attributeCode = $attributeCode ?: $this->generateCode($frontendLabel[0]);
     $attributeId = $this->getRequest()->getParam('attribute_id');
     $attribute = $this->_objectManager->create('Magento\\Catalog\\Model\\Resource\\Eav\\Attribute')->loadByCode($this->_entityTypeId, $attributeCode);
     if ($attribute->getId() && !$attributeId) {
         if (strlen($this->getRequest()->getParam('attribute_code'))) {
             $response->setAttributes(['attribute_code' => __('An attribute with this code already exists.')]);
         } else {
             $response->setAttributes(['attribute_label' => __('Attribute with the same code (%1) already exists.', $attributeCode)]);
         }
         $response->setError(true);
     }
     if ($this->getRequest()->has('new_attribute_set_name')) {
         $setName = $this->getRequest()->getParam('new_attribute_set_name');
         /** @var $attributeSet \Magento\Eav\Model\Entity\Attribute\Set */
         $attributeSet = $this->_objectManager->create('Magento\\Eav\\Model\\Entity\\Attribute\\Set');
         $attributeSet->setEntityTypeId($this->_entityTypeId)->load($setName, 'attribute_set_name');
         if ($attributeSet->getId()) {
             $setName = $this->_objectManager->get('Magento\\Framework\\Escaper')->escapeHtml($setName);
             $this->messageManager->addError(__('Attribute Set with name \'%1\' already exists.', $setName));
             $layout = $this->layoutFactory->create();
             $layout->initMessages();
             $response->setError(true);
             $response->setHtmlMessage($layout->getMessagesBlock()->getGroupedHtml());
         }
     }
     return $this->resultJsonFactory->create()->setJsonData($response->toJson());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:36,代码来源:Validate.php

示例5: getStatusHtml

 /**
  * @return string
  */
 protected function getStatusHtml()
 {
     $layout = $this->layoutFactory->create();
     /** @var \Tobai\GeoIp2\Block\Adminhtml\System\Config\Status $statusBlock */
     $statusBlock = $layout->createBlock('Tobai\\GeoIp2\\Block\\Adminhtml\\System\\Config\\Status');
     return $statusBlock->getDbStatus();
 }
开发者ID:ytorbyk,项目名称:magento2-geo-ip2,代码行数:10,代码来源:Update.php

示例6: execute

 /**
  * @return \Magento\Framework\Controller\Result\Raw
  */
 public function execute()
 {
     $layout = $this->layoutFactory->create();
     /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
     $resultRaw = $this->resultFactory->create(ResultFactory::TYPE_RAW);
     $resultRaw->setContents($layout->createBlock('Magento\\Review\\Block\\Adminhtml\\Rating\\Detailed')->setIndependentMode()->toHtml());
     return $resultRaw;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:11,代码来源:RatingItems.php

示例7: executeInternal

 /**
  * @return \Magento\Framework\Controller\Result\Raw
  */
 public function executeInternal()
 {
     $layout = $this->layoutFactory->create();
     /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
     $resultRaw = $this->resultFactory->create(ResultFactory::TYPE_RAW);
     $resultRaw->setContents($layout->createBlock('Magento\Review\Block\Adminhtml\Grid')->toHtml());
     return $resultRaw;
 }
开发者ID:nblair,项目名称:magescotch,代码行数:11,代码来源:ReviewGrid.php

示例8: execute

 /**
  * Grid with Google Content items
  *
  * @return \Magento\Framework\Controller\Result\Raw
  */
 public function execute()
 {
     /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
     $resultRaw = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_RAW);
     /** @var \Magento\GoogleShopping\Block\Adminhtml\Items\Item $block */
     $block = $this->layoutFactory->create()->createBlock('Magento\\GoogleShopping\\Block\\Adminhtml\\Items\\Item');
     return $resultRaw->setContents($block->setIndex($this->getRequest()->getParam('index'))->toHtml());
 }
开发者ID:opexsw,项目名称:magento2,代码行数:13,代码来源:Grid.php

示例9: testConstructorStructure

 public function testConstructorStructure()
 {
     $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $structure = $objectManager->get('Magento\\Framework\\View\\Layout\\Data\\Structure');
     $structure->createElement('test.container', []);
     /** @var $layout \Magento\Framework\View\LayoutInterface */
     $layout = $this->layoutFactory->create(['structure' => $structure]);
     $this->assertTrue($layout->hasElement('test.container'));
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:9,代码来源:LayoutTest.php

示例10: execute

 /**
  * Get specified tab grid
  *
  * @return \Magento\Framework\Controller\Result\Raw
  */
 public function execute()
 {
     $this->_view->getPage()->getConfig()->getTitle()->prepend(__('Products'));
     $this->productBuilder->build($this->getRequest());
     $block = $this->getRequest()->getParam('gridOnlyBlock');
     $blockClassSuffix = str_replace(' ', '_', ucwords(str_replace('_', ' ', $block)));
     /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
     $resultRaw = $this->resultRawFactory->create();
     return $resultRaw->setContents($this->layoutFactory->create()->createBlock('Magento\\Catalog\\Block\\Adminhtml\\Product\\Edit\\Tab\\' . $blockClassSuffix)->toHtml());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:GridOnly.php

示例11: execute

 /**
  * WYSIWYG editor action for ajax request
  *
  * @return \Magento\Framework\Controller\Result\Raw
  */
 public function execute()
 {
     $elementId = $this->getRequest()->getParam('element_id', md5(microtime()));
     $storeId = $this->getRequest()->getParam('store_id', 0);
     $storeMediaUrl = $this->_objectManager->get('Magento\\Store\\Model\\StoreManagerInterface')->getStore($storeId)->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
     $content = $this->layoutFactory->create()->createBlock('Magento\\Catalog\\Block\\Adminhtml\\Helper\\Form\\Wysiwyg\\Content', '', ['data' => ['editor_element_id' => $elementId, 'store_id' => $storeId, 'store_media_url' => $storeMediaUrl]]);
     /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
     $resultRaw = $this->resultRawFactory->create();
     return $resultRaw->setContents($content->toHtml());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:Wysiwyg.php

示例12: _getLayoutModel

 /**
  * Prepare a layout model with pre-loaded fixture of an update XML
  *
  * @param string $fixtureFile
  * @return \Magento\Framework\View\LayoutInterface
  */
 protected function _getLayoutModel($fixtureFile)
 {
     $this->objectManager->get('Magento\\Framework\\App\\Cache\\Type\\Layout')->clean();
     $layout = $this->layoutFactory->create();
     /** @var $xml \Magento\Framework\View\Layout\Element */
     $xml = simplexml_load_file(__DIR__ . "/_files/layout_directives_test/{$fixtureFile}", 'Magento\\Framework\\View\\Layout\\Element');
     $layout->loadString($xml->asXml());
     $layout->generateElements();
     return $layout;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:16,代码来源:LayoutDirectivesTest.php

示例13: execute

 /**
  * Chooser Source action
  *
  * @return \Magento\Framework\Controller\Result\Raw
  */
 public function execute()
 {
     $uniqId = $this->getRequest()->getParam('uniq_id');
     /** @var \Magento\Framework\View\Layout $layout */
     $layout = $this->layoutFactory->create();
     $pagesGrid = $layout->createBlock('Magento\\Cms\\Block\\Adminhtml\\Page\\Widget\\Chooser', '', ['data' => ['id' => $uniqId]]);
     $html = $pagesGrid->toHtml();
     /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
     $resultRaw = $this->resultRawFactory->create();
     return $resultRaw->setContents($html);
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:16,代码来源:Chooser.php

示例14: execute

 /**
  * Generate order history for ajax request
  *
  * @return \Magento\Framework\Controller\Result\Raw
  */
 public function execute()
 {
     $this->_initOrder();
     $layout = $this->layoutFactory->create();
     $html = $layout->createBlock('Magento\\Sales\\Block\\Adminhtml\\Order\\View\\Tab\\History')->toHtml();
     $this->_translateInline->processResponseBody($html);
     /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
     $resultRaw = $this->resultRawFactory->create();
     $resultRaw->setContents($html);
     return $resultRaw;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:16,代码来源:CommentsHistory.php

示例15: execute

 /**
  * @return \Magento\Framework\Controller\Result\Raw
  */
 public function execute()
 {
     $output = '';
     $blockTab = $this->getRequest()->getParam('block');
     $blockClassSuffix = str_replace(' ', '\\', ucwords(str_replace('_', ' ', $blockTab)));
     if (in_array($blockTab, ['tab_orders', 'tab_amounts', 'totals'])) {
         $output = $this->layoutFactory->create()->createBlock('Magento\\Backend\\Block\\Dashboard\\' . $blockClassSuffix)->toHtml();
     }
     /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
     $resultRaw = $this->resultRawFactory->create();
     return $resultRaw->setContents($output);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:AjaxBlock.php


注:本文中的Magento\Framework\View\LayoutFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。