當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Action\Context類代碼示例

本文整理匯總了PHP中Magento\Framework\App\Action\Context的典型用法代碼示例。如果您正苦於以下問題:PHP Context類的具體用法?PHP Context怎麽用?PHP Context使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Context類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setUp

 public function setUp()
 {
     $objectManagerHelper = new ObjectManagerHelper($this);
     $this->contextMock = $this->getMock('Magento\\Backend\\App\\Action\\Context', ['getRequest', 'getResponse', 'getMessageManager', 'getRedirect', 'getObjectManager', 'getSession', 'getActionFlag', 'getHelper', 'getResultRedirectFactory', 'getResultFactory'], [], '', false);
     $resultRedirectFactory = $this->getMock('Magento\\Backend\\Model\\View\\Result\\RedirectFactory', ['create'], [], '', false);
     $this->responseMock = $this->getMock('Magento\\Framework\\App\\ResponseInterface', ['setRedirect', 'sendResponse'], [], '', false);
     $this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
     $this->objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManager\\ObjectManager', ['create'], [], '', false);
     $this->messageManagerMock = $this->getMock('Magento\\Framework\\Message\\Manager', ['addSuccess', 'addError'], [], '', false);
     $this->orderCollectionMock = $this->getMockBuilder('Magento\\Sales\\Model\\Resource\\Order\\Collection')->disableOriginalConstructor()->getMock();
     $this->sessionMock = $this->getMock('Magento\\Backend\\Model\\Session', ['setIsUrlNotice'], [], '', false);
     $this->actionFlagMock = $this->getMock('Magento\\Framework\\App\\ActionFlag', ['get', 'set'], [], '', false);
     $this->helperMock = $this->getMock('\\Magento\\Backend\\Helper\\Data', ['getUrl'], [], '', false);
     $this->resultRedirectMock = $this->getMock('Magento\\Backend\\Model\\View\\Result\\Redirect', [], [], '', false);
     $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock);
     $redirectMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $resultFactoryMock = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
     $resultFactoryMock->expects($this->any())->method('create')->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT)->willReturn($redirectMock);
     $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock);
     $this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock);
     $this->contextMock->expects($this->once())->method('getResponse')->willReturn($this->responseMock);
     $this->contextMock->expects($this->once())->method('getObjectManager')->willReturn($this->objectManagerMock);
     $this->contextMock->expects($this->once())->method('getSession')->willReturn($this->sessionMock);
     $this->contextMock->expects($this->once())->method('getActionFlag')->willReturn($this->actionFlagMock);
     $this->contextMock->expects($this->once())->method('getHelper')->willReturn($this->helperMock);
     $this->contextMock->expects($this->once())->method('getResultRedirectFactory')->willReturn($resultRedirectFactory);
     $this->contextMock->expects($this->any())->method('getResultFactory')->willReturn($resultFactoryMock);
     $this->massAction = $objectManagerHelper->getObject('Magento\\Sales\\Controller\\Adminhtml\\Order\\MassCancel', ['context' => $this->contextMock]);
 }
開發者ID:nja78,項目名稱:magento2,代碼行數:29,代碼來源:MassCancelTest.php

示例2: setUp

 public function setUp()
 {
     $objectManagerHelper = new ObjectManagerHelper($this);
     $this->contextMock = $this->getMock('Magento\\Backend\\App\\Action\\Context', [], [], '', false);
     $resultRedirectFactory = $this->getMock('Magento\\Backend\\Model\\View\\Result\\RedirectFactory', [], [], '', false);
     $this->responseMock = $this->getMock('Magento\\Framework\\App\\ResponseInterface', [], [], '', false);
     $this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
     $this->objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManager\\ObjectManager', ['create'], [], '', false);
     $this->messageManagerMock = $this->getMock('Magento\\Framework\\Message\\Manager', [], [], '', false);
     $this->customerCollectionMock = $this->getMockBuilder('Magento\\Customer\\Model\\ResourceModel\\Customer\\Collection')->disableOriginalConstructor()->getMock();
     $this->customerCollectionFactoryMock = $this->getMockBuilder('Magento\\Customer\\Model\\ResourceModel\\Customer\\CollectionFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $redirectMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $resultFactoryMock = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
     $resultFactoryMock->expects($this->any())->method('create')->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT)->willReturn($redirectMock);
     $this->subscriberMock = $this->getMock('Magento\\Newsletter\\Model\\Subscriber', [], [], '', false);
     $subscriberFactoryMock = $this->getMockBuilder('Magento\\Newsletter\\Model\\SubscriberFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $subscriberFactoryMock->expects($this->any())->method('create')->willReturn($this->subscriberMock);
     $this->resultRedirectMock = $this->getMock('Magento\\Backend\\Model\\View\\Result\\Redirect', [], [], '', false);
     $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock);
     $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock);
     $this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock);
     $this->contextMock->expects($this->once())->method('getResponse')->willReturn($this->responseMock);
     $this->contextMock->expects($this->once())->method('getObjectManager')->willReturn($this->objectManagerMock);
     $this->contextMock->expects($this->any())->method('getResultRedirectFactory')->willReturn($resultRedirectFactory);
     $this->contextMock->expects($this->any())->method('getResultFactory')->willReturn($resultFactoryMock);
     $this->filterMock = $this->getMock('Magento\\Ui\\Component\\MassAction\\Filter', [], [], '', false);
     $this->filterMock->expects($this->once())->method('getCollection')->with($this->customerCollectionMock)->willReturnArgument(0);
     $this->customerCollectionFactoryMock->expects($this->once())->method('create')->willReturn($this->customerCollectionMock);
     $this->customerRepositoryMock = $this->getMockBuilder('Magento\\Customer\\Api\\CustomerRepositoryInterface')->getMockForAbstractClass();
     $this->massAction = $objectManagerHelper->getObject('Magento\\Customer\\Controller\\Adminhtml\\Index\\MassUnsubscribe', ['context' => $this->contextMock, 'filter' => $this->filterMock, 'collectionFactory' => $this->customerCollectionFactoryMock, 'customerRepository' => $this->customerRepositoryMock, 'subscriberFactory' => $subscriberFactoryMock]);
 }
開發者ID:tingyeeh,項目名稱:magento2,代碼行數:31,代碼來源:MassUnsubscribeTest.php

示例3: __construct

 /**
  * @param \Magento\Framework\App\Action\Context $context
  * @param PhpCookieManager $cookieManager
  * @param CookieMetadataFactory $cookieMetadataFactory
  */
 public function __construct(\Magento\Framework\App\Action\Context $context, PhpCookieManager $cookieManager, CookieMetadataFactory $cookieMetadataFactory)
 {
     $this->cookieManager = $cookieManager;
     $this->cookieMetadataFacory = $cookieMetadataFactory;
     $this->_response = $context->getResponse();
     $this->request = $context->getRequest();
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:12,代碼來源:CookieTester.php

示例4: setUp

 public function setUp()
 {
     $objectManagerHelper = new ObjectManagerHelper($this);
     $this->context = $this->getMock('Magento\\Backend\\App\\Action\\Context', [], [], '', false);
     $this->response = $this->getMock('Magento\\Framework\\App\\ResponseInterface', [], [], '', false);
     $this->request = $this->getMock('Magento\\Framework\\App\\RequestInterface', [], [], '', false);
     $this->objectManager = $this->getMock('Magento\\Framework\\ObjectManager\\ObjectManager', [], [], '', false);
     $this->messageManager = $this->getMock('Magento\\Framework\\Message\\Manager', [], [], '', false);
     $this->session = $this->getMock('Magento\\Backend\\Model\\Session', ['setIsUrlNotice'], [], '', false);
     $this->actionFlag = $this->getMock('Magento\\Framework\\App\\ActionFlag', [], [], '', false);
     $this->helper = $this->getMock('\\Magento\\Backend\\Helper\\Data', [], [], '', false);
     $this->resultRedirect = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $this->resultRedirectFactory = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\RedirectFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->context->expects($this->once())->method('getMessageManager')->willReturn($this->messageManager);
     $this->context->expects($this->once())->method('getObjectManager')->willReturn($this->objectManager);
     $this->context->expects($this->once())->method('getSession')->willReturn($this->session);
     $this->context->expects($this->once())->method('getActionFlag')->willReturn($this->actionFlag);
     $this->context->expects($this->once())->method('getRequest')->willReturn($this->request);
     $this->context->expects($this->once())->method('getResponse')->willReturn($this->response);
     $this->context->expects($this->once())->method('getHelper')->willReturn($this->helper);
     $this->context->expects($this->once())->method('getResultRedirectFactory')->willReturn($this->resultRedirectFactory);
     $this->resultForward = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Forward')->disableOriginalConstructor()->getMock();
     $this->resultForwardFactory = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\ForwardFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->invoiceEmail = $objectManagerHelper->getObject('Magento\\Sales\\Controller\\Adminhtml\\Order\\Invoice\\Email', ['context' => $this->context, 'resultForwardFactory' => $this->resultForwardFactory]);
 }
開發者ID:opexsw,項目名稱:magento2,代碼行數:25,代碼來源:EmailTest.php

示例5: setUp

 public function setUp()
 {
     $objectManagerHelper = new ObjectManagerHelper($this);
     $this->shipmentLoader = $this->getMock('Magento\\Shipping\\Controller\\Adminhtml\\Order\\ShipmentLoader', ['setOrderId', 'setShipmentId', 'setShipment', 'setTracking', 'load'], [], '', false);
     $this->context = $this->getMock('Magento\\Backend\\App\\Action\\Context', ['getRequest', 'getResponse', 'getMessageManager', 'getRedirect', 'getObjectManager', 'getSession', 'getActionFlag', 'getHelper', 'getResultFactory'], [], '', false);
     $this->response = $this->getMock('Magento\\Framework\\App\\ResponseInterface', ['setRedirect', 'sendResponse'], [], '', false);
     $this->request = $this->getMockBuilder('Magento\\Framework\\App\\RequestInterface')->setMethods(['isPost', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam', 'getCookie'])->getMockForAbstractClass();
     $this->objectManager = $this->getMock('Magento\\Framework\\ObjectManager\\ObjectManager', ['create'], [], '', false);
     $this->messageManager = $this->getMock('Magento\\Framework\\Message\\Manager', ['addSuccess', 'addError'], [], '', false);
     $this->session = $this->getMock('Magento\\Backend\\Model\\Session', ['setIsUrlNotice'], [], '', false);
     $this->actionFlag = $this->getMock('Magento\\Framework\\App\\ActionFlag', ['get'], [], '', false);
     $this->helper = $this->getMock('\\Magento\\Backend\\Helper\\Data', ['getUrl'], [], '', false);
     $this->resultRedirect = $this->getMock('Magento\\Backend\\Model\\View\\Result\\Redirect', [], [], '', false);
     $this->resultFactory = $this->getMock('Magento\\Framework\\Controller\\ResultFactory', ['create'], [], '', false);
     $this->resultFactory->expects($this->once())->method('create')->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT)->willReturn($this->resultRedirect);
     $this->context->expects($this->once())->method('getMessageManager')->willReturn($this->messageManager);
     $this->context->expects($this->once())->method('getRequest')->willReturn($this->request);
     $this->context->expects($this->once())->method('getResponse')->willReturn($this->response);
     $this->context->expects($this->once())->method('getObjectManager')->willReturn($this->objectManager);
     $this->context->expects($this->once())->method('getSession')->willReturn($this->session);
     $this->context->expects($this->once())->method('getActionFlag')->willReturn($this->actionFlag);
     $this->context->expects($this->once())->method('getHelper')->willReturn($this->helper);
     $this->context->expects($this->once())->method('getResultFactory')->willReturn($this->resultFactory);
     $this->shipmentEmail = $objectManagerHelper->getObject('Magento\\Shipping\\Controller\\Adminhtml\\Order\\Shipment\\Email', ['context' => $this->context, 'shipmentLoader' => $this->shipmentLoader, 'request' => $this->request, 'response' => $this->response]);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:25,代碼來源:EmailTest.php

示例6: __construct

 /**
  * @param \Magento\Framework\App\Action\Context $context
  */
 public function __construct(\Magento\Framework\App\Action\Context $context)
 {
     $this->_request = $context->getRequest();
     $this->_response = $context->getResponse();
     $this->resultRedirectFactory = $context->getResultRedirectFactory();
     $this->resultFactory = $context->getResultFactory();
 }
開發者ID:whoople,項目名稱:magento2-testing,代碼行數:10,代碼來源:AbstractAction.php

示例7: __construct

 /**
  * @param Context $context
  */
 public function __construct(Context $context)
 {
     $this->_request = $context->getRequest();
     $this->_response = $context->getResponse();
     $this->resultRedirectFactory = $context->getResultRedirectFactory();
     $this->resultFactory = $context->getResultFactory();
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:10,代碼來源:AbstractAction.php

示例8: __construct

 /**
  * @param AuthorFactory $authorFactory
  * @param Registry      $registry
  * @param Context       $context
  */
 public function __construct(AuthorFactory $authorFactory, Registry $registry, Context $context)
 {
     $this->authorFactory = $authorFactory;
     $this->registry = $registry;
     $this->resultFactory = $context->getResultFactory();
     parent::__construct($context);
 }
開發者ID:mirasvit,項目名稱:module-blog,代碼行數:12,代碼來源:View.php

示例9: __construct

 /**
  * @param Context $context
  * @param Registry $coreRegistry
  * @param DataFactory $dataFactory
  * @param CartManagementInterface $cartManagement
  * @param Onepage $onepageCheckout
  * @param JsonHelper $jsonHelper
  */
 public function __construct(Context $context, Registry $coreRegistry, DataFactory $dataFactory, CartManagementInterface $cartManagement, Onepage $onepageCheckout, JsonHelper $jsonHelper)
 {
     $this->eventManager = $context->getEventManager();
     $this->cartManagement = $cartManagement;
     $this->onepageCheckout = $onepageCheckout;
     $this->jsonHelper = $jsonHelper;
     parent::__construct($context, $coreRegistry, $dataFactory);
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:16,代碼來源:Place.php

示例10: setUp

 protected function setUp()
 {
     $this->response = $this->getMock('Magento\\Framework\\App\\ResponseInterface', ['setRedirect', 'sendResponse']);
     $this->redirect = $this->getMock('\\Magento\\Framework\\App\\Response\\RedirectInterface');
     $this->context = $this->getMock('Magento\\Framework\\App\\Action\\Context', [], [], '', false);
     $this->context->expects($this->any())->method('getResponse')->will($this->returnValue($this->response));
     $this->context->expects($this->any())->method('getRedirect')->will($this->returnValue($this->redirect));
     $this->unit = (new ObjectManager($this))->getObject('Magento\\Store\\Controller\\Store\\SwitchAction', ['context' => $this->context]);
 }
開發者ID:nja78,項目名稱:magento2,代碼行數:9,代碼來源:SwitchActionTest.php

示例11: __construct

 /**
  * AjaxPlugin constructor.
  * @param Context $context
  * @param \Boxalino\Intelligence\Helper\Data $bxHelperData
  * @param \Boxalino\Intelligence\Helper\P13n\Adapter $p13nHelper
  * @param AutocompleteInterface $autocomplete
  * @param \Boxalino\Intelligence\Helper\Autocomplete $autocompleteHelper
  */
 public function __construct(Context $context, \Boxalino\Intelligence\Helper\Data $bxHelperData, \Boxalino\Intelligence\Helper\P13n\Adapter $p13nHelper, \Boxalino\Intelligence\Helper\Autocomplete $autocompleteHelper)
 {
     $this->autocompleteHelper = $autocompleteHelper;
     $this->url = $context->getUrl();
     $this->request = $context->getRequest();
     $this->p13nHelper = $p13nHelper;
     $this->resultFactory = $context->getResultFactory();
     $this->bxHelperData = $bxHelperData;
 }
開發者ID:boxalino,項目名稱:plugin-magento2,代碼行數:17,代碼來源:AjaxPlugin.php

示例12: testExecuteException

 /**
  * Run test for execute method (exception)
  *
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @expectedExceptionMessage Wrong type of request.
  */
 public function testExecuteException()
 {
     $this->contextMock = $this->getMockBuilder('Magento\\Framework\\App\\Action\\Context')->disableOriginalConstructor()->getMock();
     $this->contextMock->expects(static::once())->method('getRequest')->willReturn($this->getRequestMock(false));
     $this->checkoutSessionMock = $this->getMockBuilder('Magento\\Checkout\\Model\\Session')->disableOriginalConstructor()->getMock();
     $this->checkoutSessionMock->expects(static::never())->method('getQuote');
     $getButtonData = new GetButtonData($this->contextMock, $this->checkoutSessionMock);
     $getButtonData->execute();
 }
開發者ID:whoople,項目名稱:magento2-testing,代碼行數:15,代碼來源:GetButtonDataTest.php

示例13: __construct

 /**
  * @param \Magento\Framework\App\Action\Context $context
  * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder
  * @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  * @param \Magento\Store\Model\StoreManagerInterface $storeManager
  */
 public function __construct(\Magento\Framework\App\Action\Context $context, \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Escaper $escaper)
 {
     $this->_transportBuilder = $transportBuilder;
     $this->inlineTranslation = $inlineTranslation;
     $this->scopeConfig = $scopeConfig;
     $this->storeManager = $storeManager;
     $this->_escaper = $escaper;
     $this->messageManager = $context->getMessageManager();
 }
開發者ID:alinmiron,項目名稱:alin-cadou,代碼行數:16,代碼來源:Mailer.php

示例14: __construct

 /**
  * @param PaymentHelper $paymentHelper
  */
 public function __construct(\Magento\Framework\App\Action\Context $context, PaymentHelper $paymentHelper, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\View\Asset\Repository $assetRepo)
 {
     $this->_request = $context->getRequest();
     $this->methodInstance = $paymentHelper->getMethodInstance($this->methodCode);
     $this->_scopeConfig = $scopeConfig;
     $this->_checkoutSession = $checkoutSession;
     $this->_storeManager = $storeManager;
     $this->_assetRepo = $assetRepo;
     $this->_context = $context;
 }
開發者ID:SummaSolutions,項目名稱:cart-magento2,代碼行數:13,代碼來源:CustomConfigProvider.php

示例15: setUp

 public function setUp()
 {
     $this->request = $this->getMockBuilder('Magento\\Framework\\App\\RequestInterface')->disableOriginalConstructor()->getMock();
     $this->response = $this->getMock('Magento\\Framework\\App\\ResponseInterface', [], [], '', false);
     $this->redirect = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Redirect')->setMethods(['setRefererOrBaseUrl'])->disableOriginalConstructor()->getMock();
     $this->redirectFactory = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\RedirectFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $this->redirectFactory->expects($this->any())->method('create')->willReturn($this->redirect);
     $this->context = $this->getMockBuilder('Magento\\Framework\\App\\Action\\Context')->disableOriginalConstructor()->getMock();
     $this->context->expects($this->any())->method('getResultRedirectFactory')->willReturn($this->redirectFactory);
     $this->action = $this->getMockForAbstractClass('Magento\\Framework\\App\\Action\\AbstractAction', [$this->context]);
 }
開發者ID:opexsw,項目名稱:magento2,代碼行數:11,代碼來源:AbstractActionTest.php


注:本文中的Magento\Framework\App\Action\Context類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。