本文整理汇总了PHP中Magento\Framework\App\ActionFlag类的典型用法代码示例。如果您正苦于以下问题:PHP ActionFlag类的具体用法?PHP ActionFlag怎么用?PHP ActionFlag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ActionFlag类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* Set up test
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function setUp()
{
$this->contextMock = $this->getMock('Magento\\Backend\\App\\Action\\Context', ['getAuthorization', 'getSession', 'getActionFlag', 'getAuth', 'getView', 'getHelper', 'getBackendUrl', 'getFormKeyValidator', 'getLocaleResolver', 'getCanUseBaseUrl', 'getRequest', 'getResponse', 'getObjectManager', 'getMessageManager'], [], '', false);
$this->response = $this->getMock('Magento\\Framework\\App\\ResponseInterface', ['setRedirect', 'sendResponse'], [], '', false);
$this->view = $this->getMock('\\Magento\\Framework\\App\\ViewInterface', ['loadLayout', 'getPage', 'getConfig', 'getTitle', 'renderLayout', 'loadLayoutUpdates', 'getDefaultLayoutHandle', 'addPageLayoutHandles', 'generateLayoutBlocks', 'generateLayoutXml', 'getLayout', 'addActionLayoutHandles', 'setIsLayoutLoaded', 'isLayoutLoaded'], [], '', false);
$this->session = $this->getMock('\\Magento\\Backend\\Model\\Session', ['setIsUrlNotice'], [], '', false);
$this->session->expects($this->any())->method('setIsUrlNotice')->willReturn($this->objectManager);
$this->actionFlag = $this->getMock('\\Magento\\Framework\\App\\ActionFlag', ['get'], [], '', false);
$this->actionFlag->expects($this->any())->method("get")->willReturn($this->objectManager);
$this->objectManager = $this->getMock('Magento\\Framework\\TestFramework\\Unit\\Helper\\ObjectManager', ['get'], [], '', false);
$this->request = $this->getMockForAbstractClass('\\Magento\\Framework\\App\\RequestInterface', ['getParam', 'getRequest'], '', false);
$this->response->expects($this->any())->method("setRedirect")->willReturn(1);
$this->page = $this->getMock('\\Magento\\Framework\\View\\Result\\Page', [], [], '', false);
$this->config = $this->getMock('\\Magento\\Framework\\View\\Result\\Page', [], [], '', false);
$this->title = $this->getMock('\\Magento\\Framework\\View\\Page\\Title', [], [], '', false);
$this->messageManager = $this->getMockForAbstractClass('\\Magento\\Framework\\Message\\ManagerInterface', ['addError', 'addSuccess'], '', false);
$this->indexReg = $this->getMock('Magento\\Framework\\Indexer\\IndexerRegistry', ['get', 'setScheduled'], [], '', false);
$this->helper = $this->getMock('\\Magento\\Backend\\Helper\\Data', ['getUrl'], [], '', false);
$this->contextMock->expects($this->any())->method("getObjectManager")->willReturn($this->objectManager);
$this->contextMock->expects($this->any())->method("getRequest")->willReturn($this->request);
$this->contextMock->expects($this->any())->method("getResponse")->willReturn($this->response);
$this->contextMock->expects($this->any())->method("getMessageManager")->willReturn($this->messageManager);
$this->contextMock->expects($this->any())->method("getSession")->willReturn($this->session);
$this->contextMock->expects($this->any())->method("getActionFlag")->willReturn($this->actionFlag);
$this->contextMock->expects($this->any())->method("getHelper")->willReturn($this->helper);
}
开发者ID:nblair,项目名称:magescotch,代码行数:30,代码来源:MassChangelogTest.php
示例2: redirectLogin
/**
* Performs redirect to login for checkout
* @param RedirectLoginInterface $expressRedirect
* @param string|null $customerBeforeAuthUrlDefault
* @return void
*/
public function redirectLogin(RedirectLoginInterface $expressRedirect, $customerBeforeAuthUrlDefault = null)
{
$this->_actionFlag->set('', 'no-dispatch', true);
foreach ($expressRedirect->getActionFlagList() as $actionKey => $actionFlag) {
$this->_actionFlag->set('', $actionKey, $actionFlag);
}
$expressRedirect->getResponse()->setRedirect($this->_objectManager->get('Magento\\Framework\\Url\\Helper\\Data')->addRequestParam($expressRedirect->getLoginUrl(), ['context' => 'checkout']));
$customerBeforeAuthUrl = $customerBeforeAuthUrlDefault;
if ($expressRedirect->getCustomerBeforeAuthUrl()) {
$customerBeforeAuthUrl = $expressRedirect->getCustomerBeforeAuthUrl();
}
if ($customerBeforeAuthUrl) {
$this->_customerSession->setBeforeAuthUrl($customerBeforeAuthUrl);
}
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:21,代码来源:ExpressRedirect.php
示例3: testExecute
/**
* @return void
*/
public function testExecute()
{
$customerId = 7;
$captchaValue = 'some-value';
$email = '[email protected]';
$redirectUrl = 'http://magento.com/customer/account/edit/';
$captcha = $this->getMock('Magento\\Captcha\\Model\\DefaultModel', [], [], '', false);
$captcha->expects($this->once())->method('isRequired')->willReturn(true);
$captcha->expects($this->once())->method('isCorrect')->with($captchaValue)->willReturn(false);
$this->helperMock->expects($this->once())->method('getCaptcha')->with(\Magento\Captcha\Observer\CheckUserEditObserver::FORM_ID)->willReturn($captcha);
$response = $this->getMock('Magento\\Framework\\App\\Response\\Http', [], [], '', false);
$request = $this->getMock('Magento\\Framework\\App\\Request\\Http', [], [], '', false);
$request->expects($this->any())->method('getPost')->with(\Magento\Captcha\Helper\Data::INPUT_NAME_FIELD_VALUE, null)->willReturn([\Magento\Captcha\Observer\CheckUserEditObserver::FORM_ID => $captchaValue]);
$controller = $this->getMock('Magento\\Framework\\App\\Action\\Action', [], [], '', false);
$controller->expects($this->any())->method('getRequest')->will($this->returnValue($request));
$controller->expects($this->any())->method('getResponse')->will($this->returnValue($response));
$this->captchaStringResolverMock->expects($this->once())->method('resolve')->with($request, \Magento\Captcha\Observer\CheckUserEditObserver::FORM_ID)->willReturn($captchaValue);
$customerDataMock = $this->getMock('\\Magento\\Customer\\Model\\Data\\Customer', [], [], '', false);
$this->customerSessionMock->expects($this->once())->method('getCustomerId')->willReturn($customerId);
$this->customerSessionMock->expects($this->atLeastOnce())->method('getCustomer')->willReturn($customerDataMock);
$this->authenticationMock->expects($this->once())->method('processAuthenticationFailure')->with($customerId);
$this->authenticationMock->expects($this->once())->method('isLocked')->with($customerId)->willReturn(true);
$this->customerSessionMock->expects($this->once())->method('logout');
$this->customerSessionMock->expects($this->once())->method('start');
$this->scopeConfigMock->expects($this->once())->method('getValue')->with('contact/email/recipient_email')->willReturn($email);
$message = __('The account is locked. Please wait and try again or contact %1.', $email);
$this->messageManagerMock->expects($this->exactly(2))->method('addError')->withConsecutive([$message], [__('Incorrect CAPTCHA')]);
$this->actionFlagMock->expects($this->once())->method('set')->with('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
$this->redirectMock->expects($this->once())->method('redirect')->with($response, '*/*/edit')->willReturn($redirectUrl);
$this->observer->execute(new \Magento\Framework\Event\Observer(['controller_action' => $controller]));
}
开发者ID:Doability,项目名称:magento2dev,代码行数:34,代码来源:CheckUserEditObserverTest.php
示例4: testExecute
/**
* @return void
*/
public function testExecute()
{
$formId = 'user_login';
$login = 'login';
$loginParams = ['username' => $login];
$customerId = 7;
$redirectUrl = 'http://magento.com/customer/account/login/';
$captchaValue = 'some-value';
$captcha = $this->getMock('Magento\\Captcha\\Model\\DefaultModel', [], [], '', false);
$captcha->expects($this->once())->method('isRequired')->with($login)->willReturn(true);
$captcha->expects($this->once())->method('isCorrect')->with($captchaValue)->willReturn(false);
$captcha->expects($this->once())->method('logAttempt')->with($login);
$this->helperMock->expects($this->once())->method('getCaptcha')->with($formId)->willReturn($captcha);
$response = $this->getMock('Magento\\Framework\\App\\Response\\Http', [], [], '', false);
$response->expects($this->once())->method('setRedirect')->with($redirectUrl);
$request = $this->getMock('Magento\\Framework\\App\\Request\\Http', [], [], '', false);
$request->expects($this->any())->method('getPost')->with('login')->willReturn($loginParams);
$controller = $this->getMock('Magento\\Framework\\App\\Action\\Action', [], [], '', false);
$controller->expects($this->any())->method('getRequest')->will($this->returnValue($request));
$controller->expects($this->any())->method('getResponse')->will($this->returnValue($response));
$this->captchaStringResolverMock->expects($this->once())->method('resolve')->with($request, $formId)->willReturn($captchaValue);
$customerDataMock = $this->getMock('\\Magento\\Customer\\Model\\Data\\Customer', ['getId'], [], '', false);
$customerDataMock->expects($this->once())->method('getId')->willReturn($customerId);
$this->customerRepositoryMock->expects($this->once())->method('get')->with($login)->willReturn($customerDataMock);
$this->authenticationMock->expects($this->once())->method('processAuthenticationFailure')->with($customerId);
$this->messageManagerMock->expects($this->once())->method('addError')->with(__('Incorrect CAPTCHA'));
$this->actionFlagMock->expects($this->once())->method('set')->with('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
$this->customerSessionMock->expects($this->once())->method('setUsername')->with($login);
$this->customerSessionMock->expects($this->once())->method('getBeforeAuthUrl')->willReturn(false);
$this->customerUrlMock->expects($this->once())->method('getLoginUrl')->willReturn($redirectUrl);
$this->observer->execute(new \Magento\Framework\Event\Observer(['controller_action' => $controller]));
}
开发者ID:Doability,项目名称:magento2dev,代码行数:35,代码来源:CheckUserLoginObserverTest.php
示例5: dispatch
/**
* Dispatch request
*
* @param RequestInterface $request
* @return ResponseInterface
* @throws NotFoundException
*/
public function dispatch(RequestInterface $request)
{
$this->_request = $request;
$profilerKey = 'CONTROLLER_ACTION:' . $request->getFullActionName();
$eventParameters = ['controller_action' => $this, 'request' => $request];
$this->_eventManager->dispatch('controller_action_predispatch', $eventParameters);
$this->_eventManager->dispatch('controller_action_predispatch_' . $request->getRouteName(), $eventParameters);
$this->_eventManager->dispatch('controller_action_predispatch_' . $request->getFullActionName(), $eventParameters);
\Magento\Framework\Profiler::start($profilerKey);
$result = null;
if ($request->isDispatched() && !$this->_actionFlag->get('', self::FLAG_NO_DISPATCH)) {
\Magento\Framework\Profiler::start('action_body');
$result = $this->execute();
\Magento\Framework\Profiler::start('postdispatch');
if (!$this->_actionFlag->get('', self::FLAG_NO_POST_DISPATCH)) {
$this->_eventManager->dispatch('controller_action_postdispatch_' . $request->getFullActionName(), $eventParameters);
$this->_eventManager->dispatch('controller_action_postdispatch_' . $request->getRouteName(), $eventParameters);
$this->_eventManager->dispatch('controller_action_postdispatch', $eventParameters);
}
\Magento\Framework\Profiler::stop('postdispatch');
\Magento\Framework\Profiler::stop('action_body');
}
\Magento\Framework\Profiler::stop($profilerKey);
return $result ?: $this->_response;
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:32,代码来源:Action.php
示例6: aroundDispatch
/**
* Dispatch request
*
* @param \Magento\Framework\App\Action\Action $subject
* @param callable $proceed
* @param \Magento\Framework\App\RequestInterface $request
* @return \Magento\Framework\App\ResponseInterface
*/
public function aroundDispatch(\Magento\Framework\App\Action\Action $subject, \Closure $proceed, \Magento\Framework\App\RequestInterface $request)
{
if (!$this->_appState->isInstalled()) {
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
$this->_response->setRedirect($this->_url->getUrl('install'));
return $this->_response;
}
return $proceed($request);
}
开发者ID:aiesh,项目名称:magento2,代码行数:17,代码来源:Install.php
示例7: testDispatchButtonNotEnabled
public function testDispatchButtonNotEnabled()
{
$resultRedirect = new \Magento\Framework\DataObject();
$this->braintreePayPalConfigMock->expects($this->once())->method('isActive')->willReturn(true);
$this->braintreePayPalConfigMock->expects($this->once())->method('isShortcutCheckoutEnabled')->willReturn(false);
$this->actionFlagMock->expects($this->once())->method('set')->with('', \Magento\Framework\App\ActionInterface::FLAG_NO_DISPATCH);
$this->resultRedirectFactoryMock->expects($this->once())->method('create')->willReturn($resultRedirect);
$this->assertEquals($resultRedirect, $this->controller->execute($this->requestMock));
$this->assertEquals('noRoute', $resultRedirect->getPath());
}
开发者ID:nblair,项目名称:magescotch,代码行数:10,代码来源:PayPalTest.php
示例8: execute
/**
* Redirects tracking popup to specific URL
* @param \Magento\Framework\Event\Observer $observer
*
* @return $this
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
$shippingInfoModel = $this->_shippingInfoFactory->create()->loadByHash($this->_request->getParam('hash'));
if ($url = $this->shipmentHelper->getTrackingUrlByShippingInfo($shippingInfoModel)) {
$controller = $observer->getControllerAction();
$controller->getResponse()->setRedirect($url);
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
}
return $observer;
}
开发者ID:SummaSolutions,项目名称:cart-magento2,代码行数:16,代码来源:TrackingPopup.php
示例9: testExecute
/**
* @return void
*/
public function testExecute()
{
$successMessage = 'All other open sessions for this account were terminated.';
$this->sessionsManager->expects($this->once())->method('logoutOtherUserSessions');
$this->messageManager->expects($this->once())->method('addSuccess')->with($successMessage);
$this->messageManager->expects($this->never())->method('addError');
$this->messageManager->expects($this->never())->method('addException');
$this->responseMock->expects($this->once())->method('setRedirect');
$this->actionFlagMock->expects($this->once())->method('get')->with('', \Magento\Backend\App\AbstractAction::FLAG_IS_URLS_CHECKED);
$this->backendHelperMock->expects($this->once())->method('getUrl');
$this->controller->execute();
}
开发者ID:Doability,项目名称:magento2dev,代码行数:15,代码来源:LogoutAllTest.php
示例10: execute
/**
* Check CAPTCHA on Contact Us page
*
* @param \Magento\Framework\Event\Observer $observer
* @return void
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
$formId = 'contact_us';
$captcha = $this->_helper->getCaptcha($formId);
if ($captcha->isRequired()) {
/** @var \Magento\Framework\App\Action\Action $controller */
$controller = $observer->getControllerAction();
if (!$captcha->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), $formId))) {
$this->messageManager->addError(__('Incorrect CAPTCHA.'));
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
$this->redirect->redirect($controller->getResponse(), 'contact/index/index');
}
}
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:20,代码来源:CheckContactUsFormObserver.php
示例11: execute
/**
* Check Captcha On Forgot Password Page
*
* @param \Magento\Framework\Event\Observer $observer
* @return $this
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
$captchaModel = $this->helper->getCaptcha(self::FORM_ID);
if ($captchaModel->isRequired()) {
/** @var \Magento\Framework\App\Action\Action $controller */
$controller = $observer->getControllerAction();
if (!$captchaModel->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), self::FORM_ID))) {
try {
$customer = $this->customerRepository->getById($this->customerSession->getCustomerId());
$this->accountManagementHelper->processCustomerLockoutData($customer->getId());
$this->customerRepository->save($customer);
} catch (NoSuchEntityException $e) {
//do nothing as customer existance is validated later in authenticate method
}
$this->workWithLock();
$this->messageManager->addError(__('Incorrect CAPTCHA'));
$this->actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
$this->redirect->redirect($controller->getResponse(), '*/*/edit');
}
}
$customer = $this->customerSession->getCustomer();
$login = $customer->getEmail();
$captchaModel->logAttempt($login);
return $this;
}
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:31,代码来源:CheckUserEditObserver.php
示例12: execute
/**
* Check Captcha On Forgot Password Page
*
* @param \Magento\Framework\Event\Observer $observer
* @return $this
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
$captchaModel = $this->helper->getCaptcha(self::FORM_ID);
if ($captchaModel->isRequired()) {
/** @var \Magento\Framework\App\Action\Action $controller */
$controller = $observer->getControllerAction();
if (!$captchaModel->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), self::FORM_ID))) {
$customerId = $this->customerSession->getCustomerId();
$this->authentication->processAuthenticationFailure($customerId);
if ($this->authentication->isLocked($customerId)) {
$this->customerSession->logout();
$this->customerSession->start();
$message = __('The account is locked. Please wait and try again or contact %1.', $this->scopeConfig->getValue('contact/email/recipient_email'));
$this->messageManager->addError($message);
}
$this->messageManager->addError(__('Incorrect CAPTCHA'));
$this->actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
$this->redirect->redirect($controller->getResponse(), '*/*/edit');
}
}
$customer = $this->customerSession->getCustomer();
$login = $customer->getEmail();
$captchaModel->logAttempt($login);
return $this;
}
开发者ID:Doability,项目名称:magento2dev,代码行数:31,代码来源:CheckUserEditObserver.php
示例13: execute
/**
* Check captcha on user login page
*
* @param \Magento\Framework\Event\Observer $observer
* @throws NoSuchEntityException
* @return $this
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
$formId = 'user_login';
$captchaModel = $this->_helper->getCaptcha($formId);
$controller = $observer->getControllerAction();
$loginParams = $controller->getRequest()->getPost('login');
$login = is_array($loginParams) && array_key_exists('username', $loginParams) ? $loginParams['username'] : null;
if ($captchaModel->isRequired($login)) {
$word = $this->captchaStringResolver->resolve($controller->getRequest(), $formId);
if (!$captchaModel->isCorrect($word)) {
try {
$customer = $this->getCustomerRepository()->get($login);
$this->getAuthentication()->processAuthenticationFailure($customer->getId());
} catch (NoSuchEntityException $e) {
//do nothing as customer existance is validated later in authenticate method
}
$this->messageManager->addError(__('Incorrect CAPTCHA'));
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
$this->_session->setUsername($login);
$beforeUrl = $this->_session->getBeforeAuthUrl();
$url = $beforeUrl ? $beforeUrl : $this->_customerUrl->getLoginUrl();
$controller->getResponse()->setRedirect($url);
}
}
$captchaModel->logAttempt($login);
return $this;
}
开发者ID:Doability,项目名称:magento2dev,代码行数:34,代码来源:CheckUserLoginObserver.php
示例14: testEmailNoOrderId
public function testEmailNoOrderId()
{
$this->request->expects($this->once())
->method('getParam')
->with('order_id')
->will($this->returnValue(null));
$this->orderRepositoryMock->expects($this->once())
->method('get')
->with(null)
->willThrowException(
new \Magento\Framework\Exception\NoSuchEntityException(__('Requested entity doesn\'t exist'))
);
$this->messageManager->expects($this->once())
->method('addError')
->with('This order no longer exists.');
$this->actionFlag->expects($this->once())
->method('set')
->with('', 'no-dispatch', true)
->will($this->returnValue(true));
$this->resultRedirect->expects($this->once())
->method('setPath')
->with('sales/*/')
->willReturnSelf();
$this->assertInstanceOf(
'Magento\Backend\Model\View\Result\Redirect',
$this->orderEmail->executeInternal()
);
}
开发者ID:nblair,项目名称:magescotch,代码行数:30,代码来源:EmailTest.php
示例15: testCheckContactUsFormRedirectsCustomerWithWarningMessageWhenCaptchaIsRequiredAndInvalid
public function testCheckContactUsFormRedirectsCustomerWithWarningMessageWhenCaptchaIsRequiredAndInvalid()
{
$formId = 'contact_us';
$captchaValue = 'some-value';
$warningMessage = 'Incorrect CAPTCHA.';
$redirectRoutePath = 'contact/index/index';
$redirectUrl = 'http://magento.com/contacts/';
$postData = ['name' => 'Some Name'];
$request = $this->getMock('Magento\\Framework\\App\\Request\\Http', [], [], '', false);
$response = $this->getMock('Magento\\Framework\\App\\Response\\Http', [], [], '', false);
$request->expects($this->any())->method('getPost')->with(\Magento\Captcha\Helper\Data::INPUT_NAME_FIELD_VALUE, null)->willReturn([$formId => $captchaValue]);
$request->expects($this->once())->method('getPostValue')->willReturn($postData);
$this->redirectMock->expects($this->once())->method('redirect')->with($response, $redirectRoutePath, [])->willReturn($redirectUrl);
$controller = $this->getMock('Magento\\Framework\\App\\Action\\Action', [], [], '', false);
$controller->expects($this->any())->method('getRequest')->willReturn($request);
$controller->expects($this->any())->method('getResponse')->willReturn($response);
$this->captchaMock->expects($this->any())->method('isRequired')->willReturn(true);
$this->captchaMock->expects($this->once())->method('isCorrect')->with($captchaValue)->willReturn(false);
$this->captchaStringResolverMock->expects($this->once())->method('resolve')->with($request, $formId)->willReturn($captchaValue);
$this->helperMock->expects($this->any())->method('getCaptcha')->with($formId)->willReturn($this->captchaMock);
$this->messageManagerMock->expects($this->once())->method('addError')->with($warningMessage);
$this->actionFlagMock->expects($this->once())->method('set')->with('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
$this->dataPersistorMock->expects($this->once())->method('set')->with($formId, $postData);
$this->checkContactUsFormObserver->execute(new \Magento\Framework\Event\Observer(['controller_action' => $controller]));
}
开发者ID:Doability,项目名称:magento2dev,代码行数:25,代码来源:CheckContactUsFormObserverTest.php
示例16: execute
/**
* Force admin to change password
*
* @param EventObserver $observer
* @return void
*/
public function execute(EventObserver $observer)
{
if (!$this->observerConfig->isPasswordChangeForced()) {
return;
}
if (!$this->authSession->isLoggedIn()) {
return;
}
$actionList = ['adminhtml_system_account_index', 'adminhtml_system_account_save', 'adminhtml_auth_logout'];
/** @var \Magento\Framework\App\Action\Action $controller */
$controller = $observer->getEvent()->getControllerAction();
/** @var \Magento\Framework\App\RequestInterface $request */
$request = $observer->getEvent()->getRequest();
if ($this->authSession->getPciAdminUserIsPasswordExpired()) {
if (!in_array($request->getFullActionName(), $actionList)) {
if ($this->authorization->isAllowed('Magento_Backend::myaccount')) {
$controller->getResponse()->setRedirect($this->url->getUrl('adminhtml/system_account/'));
$this->actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
$this->actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_POST_DISPATCH, true);
} else {
/*
* if admin password is expired and access to 'My Account' page is denied
* than we need to do force logout with error message
*/
$this->authSession->clearStorage();
$this->session->clearStorage();
$this->messageManager->addErrorMessage(__('Your password has expired; please contact your administrator.'));
$controller->getRequest()->setDispatched(false);
}
}
}
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:38,代码来源:ForceAdminPasswordChangeObserver.php
示例17: redirectSection
/**
* Redirect into response section
*
* @return void
*/
protected function redirectSection()
{
$this->actionFlag->expects($this->once())->method('get')->with('', \Magento\Backend\App\AbstractAction::FLAG_IS_URLS_CHECKED)->will($this->returnValue(true));
$this->sessionMock->expects($this->once())->method('setIsUrlNotice')->with(true);
$this->helperMock->expects($this->once())->method('getUrl')->will($this->returnValue('redirect-path'));
$this->responseMock->expects($this->once())->method('setRedirect');
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:12,代码来源:PrintLabelTest.php
示例18: testDispatchPostDispatch
public function testDispatchPostDispatch()
{
$this->_requestMock->expects($this->exactly(3))->method('getFullActionName')->will($this->returnValue(self::FULL_ACTION_NAME));
$this->_requestMock->expects($this->exactly(2))->method('getRouteName')->will($this->returnValue(self::ROUTE_NAME));
$expectedEventParameters = ['controller_action' => $this->action, 'request' => $this->_requestMock];
$this->_eventManagerMock->expects($this->at(0))->method('dispatch')->with('controller_action_predispatch', $expectedEventParameters);
$this->_eventManagerMock->expects($this->at(1))->method('dispatch')->with('controller_action_predispatch_' . self::ROUTE_NAME, $expectedEventParameters);
$this->_eventManagerMock->expects($this->at(2))->method('dispatch')->with('controller_action_predispatch_' . self::FULL_ACTION_NAME, $expectedEventParameters);
$this->_requestMock->expects($this->once())->method('isDispatched')->will($this->returnValue(true));
$this->_actionFlagMock->expects($this->at(0))->method('get')->with('', Action::FLAG_NO_DISPATCH)->will($this->returnValue(false));
// _forward expectations
$this->_requestMock->expects($this->once())->method('initForward');
$this->_requestMock->expects($this->once())->method('setParams')->with(self::$actionParams);
$this->_requestMock->expects($this->once())->method('setControllerName')->with(self::CONTROLLER_NAME);
$this->_requestMock->expects($this->once())->method('setModuleName')->with(self::MODULE_NAME);
$this->_requestMock->expects($this->once())->method('setActionName')->with(self::ACTION_NAME);
$this->_requestMock->expects($this->once())->method('setDispatched')->with(false);
// _redirect expectations
$this->_redirectMock->expects($this->once())->method('redirect')->with($this->_responseMock, self::FULL_ACTION_NAME, self::$actionParams);
$this->_actionFlagMock->expects($this->at(1))->method('get')->with('', Action::FLAG_NO_POST_DISPATCH)->will($this->returnValue(false));
$this->_eventManagerMock->expects($this->at(3))->method('dispatch')->with('controller_action_postdispatch_' . self::FULL_ACTION_NAME, $expectedEventParameters);
$this->_eventManagerMock->expects($this->at(4))->method('dispatch')->with('controller_action_postdispatch_' . self::ROUTE_NAME, $expectedEventParameters);
$this->_eventManagerMock->expects($this->at(5))->method('dispatch')->with('controller_action_postdispatch', $expectedEventParameters);
$this->assertEquals($this->_responseMock, $this->action->dispatch($this->_requestMock));
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:25,代码来源:ActionTest.php
示例19: prepareRedirect
/**
* @param string $path
* @param array $arguments
* @param int $index
*/
protected function prepareRedirect($path, $arguments, $index)
{
$this->actionFlag->expects($this->any())->method('get')->with('', 'check_url_settings')->will($this->returnValue(true));
$this->session->expects($this->any())->method('setIsUrlNotice')->with(true);
$url = $path . '/' . (!empty($arguments) ? $arguments['shipment_id'] : '');
$this->helper->expects($this->at($index))->method('getUrl')->with($path, $arguments)->will($this->returnValue($url));
$this->response->expects($this->at($index))->method('setRedirect')->with($url);
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:EmailTest.php
示例20: execute
/**
* Check Captcha On Checkout as Guest Page
*
* @param \Magento\Framework\Event\Observer $observer
* @return $this
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
$formId = 'guest_checkout';
$captchaModel = $this->_helper->getCaptcha($formId);
$checkoutMethod = $this->_typeOnepage->getQuote()->getCheckoutMethod();
if ($checkoutMethod == \Magento\Checkout\Model\Type\Onepage::METHOD_GUEST) {
if ($captchaModel->isRequired()) {
$controller = $observer->getControllerAction();
if (!$captchaModel->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), $formId))) {
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
$result = ['error' => 1, 'message' => __('Incorrect CAPTCHA')];
$controller->getResponse()->representJson($this->jsonHelper->jsonEncode($result));
}
}
}
return $this;
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:23,代码来源:CheckGuestCheckoutObserver.php
注:本文中的Magento\Framework\App\ActionFlag类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论