當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。