本文整理汇总了PHP中Magento\Framework\View\LayoutFactory类的典型用法代码示例。如果您正苦于以下问题:PHP LayoutFactory类的具体用法?PHP LayoutFactory怎么用?PHP LayoutFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LayoutFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: setUp
protected function setUp()
{
$this->layout = $this->getMockBuilder('Magento\\Framework\\View\\Layout')->setMethods(['addHandle', 'getUpdate', 'isLayoutDefined'])->disableOriginalConstructor()->getMock();
$this->layoutFactory = $this->getMockBuilder('Magento\\Framework\\View\\LayoutFactory')->disableOriginalConstructor()->getMock();
$this->layoutFactory->expects($this->any())->method('create')->will($this->returnValue($this->layout));
$this->layoutMerge = $this->getMockBuilder('Magento\\Framework\\View\\Model\\Layout\\Merge')->disableOriginalConstructor()->getMock();
$this->layout->expects($this->any())->method('getUpdate')->will($this->returnValue($this->layoutMerge));
$this->request = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
$this->pageConfig = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Config')->disableOriginalConstructor()->getMock();
$this->viewFileSystem = $this->getMockBuilder('Magento\\Framework\\View\\FileSystem')->disableOriginalConstructor()->getMock();
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->context = $objectManagerHelper->getObject('Magento\\Framework\\View\\Element\\Template\\Context', ['layout' => $this->layout, 'request' => $this->request, 'viewFileSystem' => $this->viewFileSystem, 'pageConfig' => $this->pageConfig]);
$this->translateInline = $this->getMock('Magento\\Framework\\Translate\\InlineInterface');
$this->pageConfigRenderer = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Config\\Renderer')->disableOriginalConstructor()->getMock();
$pageConfigRendererFactory = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Config\\RendererFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
$pageConfigRendererFactory->expects($this->once())->method('create')->with(['pageConfig' => $this->pageConfig])->willReturn($this->pageConfigRenderer);
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->page = $objectManagerHelper->getObject('Magento\\Framework\\View\\Result\\Page', ['isIsolated' => true, 'layoutFactory' => $this->layoutFactory, 'context' => $this->context, 'translateInline' => $this->translateInline, 'pageConfigRendererFactory' => $pageConfigRendererFactory]);
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:19,代码来源:PageTest.php
示例4: 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
示例5: 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
示例6: 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
示例7: 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
示例8: 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
示例9: 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
示例10: 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
示例11: 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
示例12: 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
示例13: _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
示例14: 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
示例15: 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
示例16: 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
示例17: execute
/**
* Grid Action
* Display list of products related to current category
*
* @return \Magento\Framework\Controller\Result\Raw
*/
public function execute()
{
$category = $this->_initCategory(true);
if (!$category) {
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
return $resultRedirect->setPath('catalog/*/', ['_current' => true, 'id' => null]);
}
/** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
$resultRaw = $this->resultRawFactory->create();
return $resultRaw->setContents($this->layoutFactory->create()->createBlock('Magento\\Catalog\\Block\\Adminhtml\\Category\\Tab\\Product', 'category.product.grid')->toHtml());
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:18,代码来源:Grid.php
示例18: execute
/**
* Get available attribute sets
*
* @return \Magento\Framework\Controller\Result\Raw
* @throws \Exception
*/
public function execute()
{
try {
/** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
$resultRaw = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_RAW);
return $resultRaw->setContents($this->layoutFactory->create()->getBlockSingleton('Magento\\GoogleShopping\\Block\\Adminhtml\\Types\\Edit\\Form')->getAttributeSetsSelectElement($this->getRequest()->getParam('target_country'))->toHtml());
} catch (\Exception $e) {
$this->_objectManager->get('Psr\\Log\\LoggerInterface')->critical($e);
// just need to output text with error
$this->messageManager->addError(__("We can't load attribute sets."));
}
}
开发者ID:niranjanssiet,项目名称:magento2,代码行数:18,代码来源:LoadAttributeSets.php
示例19: execute
/**
* Get Google Content attributes list
*
* @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);
try {
$resultRaw->setContents($this->layoutFactory->create()->createBlock('Magento\\GoogleShopping\\Block\\Adminhtml\\Types\\Edit\\Attributes')->setAttributeSetId($this->getRequest()->getParam('attribute_set_id'))->setTargetCountry($this->getRequest()->getParam('target_country'))->setAttributeSetSelected(true)->toHtml());
} catch (\Exception $e) {
$this->_objectManager->get('Psr\\Log\\LoggerInterface')->critical($e);
// just need to output text with error
$this->messageManager->addError(__('We can\'t load attributes right now.'));
}
return $resultRaw;
}
开发者ID:niranjanssiet,项目名称:magento2,代码行数:18,代码来源:LoadAttributes.php
示例20: testUpdate
public function testUpdate()
{
$statusInfo = 'some status info';
$data = ['status' => 'success', 'message' => __('Database(s) successfully updated.'), 'status_info' => $statusInfo];
$this->resultJson->expects($this->once())->method('setData')->with($data)->willReturnSelf();
$this->updaterSelected->expects($this->once())->method('update')->willReturnSelf();
$statusBlock = $this->getMockBuilder('Tobai\\GeoIp2\\Block\\Adminhtml\\System\\Config\\Status')->disableOriginalConstructor()->getMock();
$layout = $this->getMock('Magento\\Framework\\View\\LayoutInterface');
$this->layoutFactory->expects($this->once())->method('create')->willReturn($layout);
$layout->expects($this->once())->method('createBlock')->with('Tobai\\GeoIp2\\Block\\Adminhtml\\System\\Config\\Status')->willReturn($statusBlock);
$statusBlock->expects($this->once())->method('getDbStatus')->willReturn($statusInfo);
$this->logger->expects($this->never())->method('critical');
$this->assertSame($this->resultJson, $this->controllerUpdate->execute());
}
开发者ID:ytorbyk,项目名称:magento2-geo-ip2,代码行数:14,代码来源:UpdateTest.php
注:本文中的Magento\Framework\View\LayoutFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论