本文整理汇总了PHP中Magento\Framework\App\Action\Action::execute方法的典型用法代码示例。如果您正苦于以下问题:PHP Action::execute方法的具体用法?PHP Action::execute怎么用?PHP Action::execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\Action\Action
的用法示例。
在下文中一共展示了Action::execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Check customer authentication for some actions
*
* @param RequestInterface $request
* @return \Magento\Framework\App\ResponseInterface
*/
public function execute(RequestInterface $request)
{
if (!$this->_customerSession->authenticate()) {
$this->_actionFlag->set('', 'no-dispatch', true);
}
return parent::execute($request);
}
示例2: execute
/**
* {@inheritdoc}
*/
public function execute(\Magento\Framework\App\RequestInterface $request)
{
if (!$this->_getCheckout()->getCustomer()->getId()) {
return $this->_redirect('customer/account/login');
}
return parent::execute($request);
}
示例3: execute
/**
* Check customer authentication for some actions
*
* @param \Magento\Framework\App\RequestInterface $request
* @return \Magento\Framework\App\ResponseInterface
*/
public function execute(RequestInterface $request)
{
if (!$this->customerSession->authenticate()) {
$this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true);
}
return parent::execute($request);
}
示例4: execute
/**
* Dispatch request
*
* @param RequestInterface $request
* @return \Magento\Framework\App\ResponseInterface
* @throws \Magento\Framework\Exception\NotFoundException
*/
public function execute(RequestInterface $request)
{
if (!$this->scopeConfig->isSetFlag(self::XML_PATH_ENABLED, ScopeInterface::SCOPE_STORE)) {
throw new NotFoundException(__('Page not found.'));
}
return parent::execute($request);
}
示例5: execute
/**
* Check customer authentication
*
* @param RequestInterface $request
* @return \Magento\Framework\App\ResponseInterface
*/
public function execute(RequestInterface $request)
{
$loginUrl = $this->_objectManager->get('Magento\\Customer\\Model\\Url')->getLoginUrl();
if (!$this->_customerSession->authenticate($loginUrl)) {
$this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true);
}
return parent::execute($request);
}
示例6: execute
/**
* Check customer authentication
*
* @param RequestInterface $request
* @return \Magento\Framework\App\ResponseInterface
*/
public function execute(RequestInterface $request)
{
if (!$request->isDispatched()) {
return parent::execute($request);
}
if (!$this->_getSession()->authenticate()) {
$this->_actionFlag->set('', 'no-dispatch', true);
}
return parent::execute($request);
}
示例7: execute
/**
* Check customer authentication for some actions
*
* @param \Magento\Framework\App\RequestInterface $request
* @return \Magento\Framework\App\ResponseInterface
*/
public function execute(RequestInterface $request)
{
if (!$this->customerSession->authenticate()) {
$this->_actionFlag->set('', 'no-dispatch', true);
if (!$this->customerSession->getBeforeUrl()) {
$this->customerSession->setBeforeUrl($this->_redirect->getRefererUrl());
}
}
return parent::execute($request);
}
示例8: execute
/**
* Check whether payment method is enabled
*
* @param RequestInterface $request
* @return \Magento\Framework\Controller\Result\Redirect|\Magento\Framework\App\ResponseInterface
*/
public function execute(RequestInterface $request)
{
if (!$this->braintreePayPalConfig->isActive() || !$this->braintreePayPalConfig->isShortcutCheckoutEnabled()) {
$this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true);
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
$resultRedirect->setPath('noRoute');
return $resultRedirect;
}
return parent::execute($request);
}
示例9: execute
/**
* Dispatch request
*
* @param \Magento\Framework\App\RequestInterface $request
* @return \Magento\Framework\App\ResponseInterface
*/
public function execute(RequestInterface $request)
{
$searchTerms = $this->scopeConfig->getValue(
'catalog/seo/search_terms',
ScopeInterface::SCOPE_STORE
);
if (!$searchTerms) {
$this->_redirect('noroute');
$this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true);
}
return parent::execute($request);
}
示例10: execute
/**
* Check customer authentication
*
* @param RequestInterface $request
* @return \Magento\Framework\Controller\Result\Redirect|\Magento\Framework\App\ResponseInterface
*/
public function execute(RequestInterface $request)
{
$loginUrl = $this->customerUrl->getLoginUrl();
if (!$this->customerSession->authenticate($loginUrl)) {
$this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true);
}
if (!$this->config->useVault()) {
$this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true);
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
$resultRedirect->setPath('noRoute');
return $resultRedirect;
}
return parent::execute($request);
}
示例11: testExecute
public function testExecute()
{
// Define test expectations
$this->resultPageFactory->expects($this->once())->method('create')->willReturn($this->page);
$this->assertSame($this->page, $this->controller->execute());
}
示例12: execute
/**
* @param \Magento\Framework\App\RequestInterface $request
* @return \Magento\Framework\App\ResponseInterface
*/
public function execute(\Magento\Framework\App\RequestInterface $request)
{
if (!$this->_processUrlKeys()) {
return parent::execute($request);
}
if ($request->isDispatched() && $request->getActionName() !== 'denied' && !$this->_isAllowed()) {
$this->_response->setStatusHeader(403, '1.1', 'Forbidden');
if (!$this->_auth->isLoggedIn()) {
return $this->_redirect('*/auth/login');
}
$this->_view->loadLayout(['default', 'adminhtml_denied'], true, true, false);
$this->_view->renderLayout();
$this->_request->setDispatched(true);
return $this->_response;
}
if ($this->_isUrlChecked()) {
$this->_actionFlag->set('', self::FLAG_IS_URLS_CHECKED, true);
}
$this->_processLocaleSettings();
return parent::execute($request);
}
示例13: execute
public function execute()
{
// echo "ONE";
// exit;
parent::execute();
}
示例14: execute
/**
* Dispatch request
*
* @param RequestInterface $request
* @return \Magento\Framework\App\ResponseInterface
*/
public function execute(RequestInterface $request)
{
$allowGuest = $this->_objectManager->get('Magento\Review\Helper\Data')->getIsGuestAllowToWrite();
if (!$request->isDispatched()) {
return parent::execute($request);
}
if (!$allowGuest && $request->getActionName() == 'post' && $request->isPost()) {
if (!$this->customerSession->isLoggedIn()) {
$this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true);
$this->customerSession->setBeforeAuthUrl($this->_url->getUrl('*/*/*', ['_current' => true]));
$this->_reviewSession->setFormData(
$request->getPostValue()
)->setRedirectUrl(
$this->_redirect->getRefererUrl()
);
$this->getResponse()->setRedirect(
$this->_objectManager->get('Magento\Customer\Model\Url')->getLoginUrl()
);
}
}
return parent::execute($request);
}
示例15: execute
/**
* Check if module is enabled
* If allow only for customer - redirect to login page
*
* @param RequestInterface $request
* @return \Magento\Framework\App\ResponseInterface
* @throws \Magento\Framework\Exception\NotFoundException
*/
public function execute(RequestInterface $request)
{
/* @var $helper \Magento\SendFriend\Helper\Data */
$helper = $this->_objectManager->get('Magento\SendFriend\Helper\Data');
/* @var $session \Magento\Customer\Model\Session */
$session = $this->_objectManager->get('Magento\Customer\Model\Session');
if (!$helper->isEnabled()) {
throw new NotFoundException(__('Page not found.'));
}
if (!$helper->isAllowForGuest() && !$session->authenticate()) {
$this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true);
if ($this->getRequest()->getActionName() == 'sendemail') {
$session->setBeforeAuthUrl($this->_url->getUrl('sendfriend/product/send', ['_current' => true]));
$this->_objectManager->get('Magento\Catalog\Model\Session')
->setSendfriendFormData($request->getPostValue());
}
}
return parent::execute($request);
}