本文整理汇总了PHP中Magento\Framework\App\ViewInterface类的典型用法代码示例。如果您正苦于以下问题:PHP ViewInterface类的具体用法?PHP ViewInterface怎么用?PHP ViewInterface使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ViewInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPaymentMethodsHtml
/**
* Get payment method step html
*
* @param \Magento\Framework\App\ViewInterface $view
* @return string
*/
public function getPaymentMethodsHtml(\Magento\Framework\App\ViewInterface $view)
{
$layout = $view->getLayout();
$update = $layout->getUpdate();
$update->load('checkout_onepage_paymentmethod');
$layout->generateXml();
$layout->generateElements();
$output = $layout->getOutput();
return $output;
}
示例2: setUp
protected function setUp()
{
$this->_eventManagerMock = $this->getMock('Magento\\Framework\\Event\\ManagerInterface', [], [], '', false);
$this->_actionFlagMock = $this->getMock('Magento\\Framework\\App\\ActionFlag', [], [], '', false);
$this->_redirectMock = $this->getMock('Magento\\Framework\\App\\Response\\RedirectInterface', [], [], '', false);
$this->_requestMock = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
$this->_responseMock = $this->getMock('Magento\\Framework\\App\\ResponseInterface', [], [], '', false);
$this->pageConfigMock = $this->getMock('Magento\\Framework\\View\\Page\\Config', ['getConfig'], [], '', false);
$this->viewMock = $this->getMock('Magento\\Framework\\App\\ViewInterface');
$this->viewMock->expects($this->any())->method('getPage')->will($this->returnValue($this->pageConfigMock));
$this->pageConfigMock->expects($this->any())->method('getConfig')->will($this->returnValue(1));
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->action = $this->objectManagerHelper->getObject('Magento\\Framework\\App\\Test\\Unit\\Action\\ActionFake', ['request' => $this->_requestMock, 'response' => $this->_responseMock, 'eventManager' => $this->_eventManagerMock, 'redirect' => $this->_redirectMock, 'actionFlag' => $this->_actionFlagMock, 'view' => $this->viewMock]);
\Magento\Framework\Profiler::disable();
}
示例3: prepareAndRender
/**
* Prepares product view page - inits layout and all needed stuff
*
* $params can have all values as $params in \Magento\Catalog\Helper\Product - initProduct().
* Plus following keys:
* - 'buy_request' - \Magento\Framework\Object holding buyRequest to configure product
* - 'specify_options' - boolean, whether to show 'Specify options' message
* - 'configure_mode' - boolean, whether we're in Configure-mode to edit product configuration
*
* @param int $productId
* @param \Magento\Framework\App\Action\Action $controller
* @param null|\Magento\Framework\Object $params
*
* @return \Magento\Catalog\Helper\Product\View
* @throws \Magento\Framework\Model\Exception
*/
public function prepareAndRender($productId, $controller, $params = null)
{
// Prepare data
$productHelper = $this->_catalogProduct;
if (!$params) {
$params = new \Magento\Framework\Object();
}
// Standard algorithm to prepare and render product view page
$product = $productHelper->initProduct($productId, $controller, $params);
if (!$product) {
throw new \Magento\Framework\Model\Exception(__('Product is not loaded'), $this->ERR_NO_PRODUCT_LOADED);
}
$buyRequest = $params->getBuyRequest();
if ($buyRequest) {
$productHelper->prepareProductOptions($product, $buyRequest);
}
if ($params->hasConfigureMode()) {
$product->setConfigureMode($params->getConfigureMode());
}
$this->_eventManager->dispatch('catalog_controller_product_view', array('product' => $product));
$this->_catalogSession->setLastViewedProductId($product->getId());
$this->initProductLayout($product, $controller, $params);
if ($controller instanceof \Magento\Catalog\Controller\Product\View\ViewInterface) {
$this->_view->getLayout()->initMessages($this->messageGroups);
} else {
throw new \Magento\Framework\Model\Exception(__('Bad controller interface for showing product'), $this->ERR_BAD_CONTROLLER_INTERFACE);
}
$this->_view->renderLayout();
return $this;
}
示例4: setUp
public function setUp()
{
$this->request = $this->getMock('Magento\\Framework\\App\\RequestInterface');
$this->response = $this->getMock('Magento\\Framework\\App\\ResponseInterface');
$this->categoryHelper = $this->getMock('Magento\\Catalog\\Helper\\Category', [], [], '', false);
$this->objectManager = $this->getMock('Magento\\Framework\\ObjectManager', [], [], '', false);
$this->eventManager = $this->getMock('Magento\\Framework\\Event\\ManagerInterface');
$this->update = $this->getMock('Magento\\Framework\\View\\Layout\\ProcessorInterface');
$this->layout = $this->getMock('Magento\\Framework\\View\\Layout', [], [], '', false);
$this->layout->expects($this->any())->method('getUpdate')->will($this->returnValue($this->update));
$this->view = $this->getMock('Magento\\Framework\\App\\ViewInterface');
$this->view->expects($this->any())->method('getLayout')->will($this->returnValue($this->layout));
$this->context = $this->getMock('Magento\\Backend\\App\\Action\\Context', [], [], '', false);
$this->context->expects($this->any())->method('getRequest')->will($this->returnValue($this->request));
$this->context->expects($this->any())->method('getResponse')->will($this->returnValue($this->response));
$this->context->expects($this->any())->method('getObjectManager')->will($this->returnValue($this->objectManager));
$this->context->expects($this->any())->method('getEventManager')->will($this->returnValue($this->eventManager));
$this->context->expects($this->any())->method('getView')->will($this->returnValue($this->view));
$this->category = $this->getMock('Magento\\Catalog\\Model\\Category', [], [], '', false);
$this->categoryFactory = $this->getMock('Magento\\Catalog\\Model\\CategoryFactory', ['create'], [], '', false);
$this->store = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
$this->storeManager = $this->getMock('Magento\\Store\\Model\\StoreManagerInterface');
$this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($this->store));
$this->catalogDesign = $this->getMock('Magento\\Catalog\\Model\\Design', [], [], '', false);
$this->layoutHelper = $this->getMock('Magento\\Theme\\Helper\\Layout', [], [], '', false);
$this->action = (new ObjectManager($this))->getObject('Magento\\Catalog\\Controller\\Category\\View', ['context' => $this->context, 'catalogDesign' => $this->catalogDesign, 'categoryFactory' => $this->categoryFactory, 'storeManager' => $this->storeManager]);
}
示例5: testExecute
/**
* @return void
*/
public function testExecute()
{
$titleMock = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Title')->disableOriginalConstructor()->getMock();
$titleMock->expects($this->once())->method('prepend')->with(new Phrase('Account Activity'));
$this->viewMock->expects($this->any())->method('getPage')->willReturn(new DataObject(['config' => new DataObject(['title' => $titleMock])]));
$this->controller->execute();
}
示例6: execute
/**
* Push `trackSiteSearch' to tracker on search result page
*
* @param \Magento\Framework\Event\Observer $observer
* @return \Henhed\Piwik\Observer\SearchResultObserver
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
if (!$this->_dataHelper->isTrackingEnabled()) {
return $this;
}
$query = $this->_queryFactory->get();
$piwikBlock = $this->_view->getLayout()->getBlock('piwik.tracker');
/* @var $query \Magento\Search\Model\Query */
/* @var $piwikBlock \Henhed\Piwik\Block\Piwik */
$keyword = $query->getQueryText();
$resultsCount = $query->getNumResults();
if (is_null($resultsCount)) {
// If this is a new search query the result count hasn't been saved
// yet so we have to fetch it from the search result block instead.
$resultBock = $this->_view->getLayout()->getBlock('search.result');
/* @var $resultBock \Magento\CatalogSearch\Block\Result */
if ($resultBock) {
$resultsCount = $resultBock->getResultCount();
}
}
if (is_null($resultsCount)) {
$this->_piwikTracker->trackSiteSearch($keyword);
} else {
$this->_piwikTracker->trackSiteSearch($keyword, false, (int) $resultsCount);
}
if ($piwikBlock) {
// Don't push `trackPageView' when `trackSiteSearch' is set
$piwikBlock->setSkipTrackPageView(true);
}
return $this;
}
示例7: testExecuteInternal
public function testExecuteInternal()
{
$this->view->expects($this->once())
->method('loadLayout')
->with(false);
$this->view->expects($this->once())
->method('renderLayout');
$this->controller->executeInternal();
}
示例8: testExecute
public function testExecute()
{
$layout = $this->getMock('\\Magento\\Framework\\View\\Layout', ['getBlock', 'initMessages'], [], '', false);
$block = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Element\\AbstractBlock', ['setFormAction'], '', false);
$layout->expects($this->once())->method('getBlock')->with('contactForm')->will($this->returnValue($block));
$this->_view->expects($this->once())->method('loadLayout');
$this->_view->expects($this->exactly(1))->method('getLayout')->will($this->returnValue($layout));
$this->_view->expects($this->once())->method('renderLayout');
$this->_controller->execute();
}
示例9: testExecute
public function testExecute()
{
$this->view->expects($this->any())->method('loadLayout')->will($this->returnValue(1));
$this->view->expects($this->any())->method('getPage')->will($this->returnValue($this->page));
$this->page->expects($this->any())->method('getConfig')->will($this->returnValue($this->config));
$this->config->expects($this->any())->method('getTitle')->will($this->returnValue($this->title));
$this->title->expects($this->any())->method('prepend')->with(__('Index Management'))->will($this->returnValue(1));
$this->view->expects($this->any())->method('renderLayout')->will($this->returnValue(1));
$this->object->execute();
}
示例10: testGetCustomerDepersonalizeCustomerData
/**
* test getCustomer method, method returns depersonalized customer Data
*/
public function testGetCustomerDepersonalizeCustomerData()
{
$this->requestMock->expects($this->once())->method('isAjax')->will($this->returnValue(false));
$this->layoutMock->expects($this->once())->method('isCacheable')->will($this->returnValue(true));
$this->viewMock->expects($this->once())->method('isLayoutLoaded')->will($this->returnValue(true));
$this->moduleManagerMock->expects($this->once())->method('isEnabled')->with($this->equalTo('Magento_PageCache'))->will($this->returnValue(true));
$this->customerSessionMock->expects($this->once())->method('getCustomerGroupId')->will($this->returnValue($this->customerGroupId));
$this->customerInterfaceFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->customerDataMock));
$this->customerDataMock->expects($this->once())->method('setGroupId')->with($this->equalTo($this->customerGroupId))->will($this->returnSelf());
$this->assertEquals($this->customerDataMock, $this->currentCustomer->getCustomer());
}
示例11: testExecute
/**
* @covers \Magento\Authorizenet\Controller\Directpost\Payment\Redirect::execute
*/
public function testExecute()
{
$url = 'http://test.com/redirect?=test';
$params = ['order_success' => $url];
$this->request->expects(static::once())->method('getParams')->willReturn($params);
$this->coreRegistry->expects(static::once())->method('register')->with(Iframe::REGISTRY_KEY, []);
$this->view->expects(static::once())->method('addPageLayoutHandles');
$this->view->expects(static::once())->method('loadLayout')->with(false)->willReturnSelf();
$this->view->expects(static::once())->method('renderLayout');
$this->controller->execute();
}
示例12: getItems
/**
* Get wishlist items
*
* @return array
*/
protected function getItems()
{
$this->view->loadLayout();
$collection = $this->wishlistHelper->getWishlistItemCollection();
$collection->clear()->setPageSize(self::SIDEBAR_ITEMS_NUMBER)->setInStockFilter(true)->setOrder('added_at');
$items = [];
foreach ($collection as $wishlistItem) {
$items[] = $this->getItemData($wishlistItem);
}
return $items;
}
示例13: testExecute
public function testExecute()
{
$layout = $this->getMock('\\Magento\\Framework\\View\\LayoutInterface');
$block = $this->getMockBuilder('Magento\\Bundle\\Block\\Adminhtml\\Catalog\\Product\\Edit\\Tab\\Bundle\\Option\\Search\\Grid')->disableOriginalConstructor()->setMethods(['setIndex', 'toHtml'])->getMock();
$this->response->expects($this->once())->method('setBody')->willReturnSelf();
$this->request->expects($this->once())->method('getParam')->with('index')->willReturn('index');
$this->view->expects($this->once())->method('getLayout')->willReturn($layout);
$layout->expects($this->once())->method('createBlock')->willReturn($block);
$block->expects($this->once())->method('setIndex')->willReturnSelf();
$block->expects($this->once())->method('toHtml')->willReturnSelf();
$this->assertEquals($this->response, $this->controller->execute());
}
示例14: testExecute
public function testExecute()
{
$product = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->setMethods(['_wakeup', 'getId'])->getMock();
$layout = $this->getMock('\\Magento\\Framework\\View\\LayoutInterface');
$block = $this->getMockBuilder('Magento\\Bundle\\Block\\Adminhtml\\Catalog\\Product\\Edit\\Tab\\Bundle')->disableOriginalConstructor()->setMethods(['setIndex', 'toHtml'])->getMock();
$this->productBuilder->expects($this->once())->method('build')->with($this->request)->willReturn($product);
$this->initializationHelper->expects($this->any())->method('initialize')->willReturn($product);
$this->response->expects($this->once())->method('setBody')->willReturnSelf();
$this->view->expects($this->once())->method('getLayout')->willReturn($layout);
$layout->expects($this->once())->method('createBlock')->willReturn($block);
$block->expects($this->once())->method('toHtml')->willReturnSelf();
$this->controller->execute();
}
示例15: testExecute
public function testExecute()
{
$product = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->setMethods(['_wakeup', 'getId'])->getMock();
$layout = $this->getMock('\\Magento\\Framework\\View\\LayoutInterface');
$block = $this->getMockBuilder('Magento\\ConfigurableProduct\\Block\\Adminhtml\\Product\\Attribute\\NewAttribute\\Product\\Created')->disableOriginalConstructor()->setMethods(['setIndex', 'toHtml'])->getMock();
$this->view->expects($this->once())->method('loadLayout')->with('popup')->willReturnSelf();
$this->productBuilder->expects($this->once())->method('build')->with($this->request)->willReturn($product);
$this->view->expects($this->any())->method('getLayout')->willReturn($layout);
$layout->expects($this->once())->method('createBlock')->willReturn($block);
$layout->expects($this->once())->method('setChild')->willReturnSelf();
$this->view->expects($this->any())->method('renderLayout')->willReturnSelf();
$this->controller->execute();
}