예제 #1
0
 /**
  * Display reset forgotten password form
  *
  * User is redirected on this action when he clicks on the corresponding link in password reset confirmation email
  *
  * @return \Magento\Framework\Controller\Result\Forward
  */
 public function execute()
 {
     /** @var \Magento\Framework\Controller\Result\Forward $resultForward */
     $resultForward = $this->resultForwardFactory->create();
     $resultForward->forward('createPassword');
     return $resultForward;
 }
예제 #2
0
파일: View.php 프로젝트: pleminh/Gemtoo
 /**
  * @return \Magento\Framework\Controller\Result\Forward|\Magento\Framework\View\Result\Page
  */
 public function execute()
 {
     $articleId = (int) $this->getRequest()->getParam('id');
     $article = $this->articleFactory->create();
     $article->load($articleId);
     if (!$article->isActive()) {
         $resultForward = $this->resultForwardFactory->create();
         $resultForward->forward('noroute');
         return $resultForward;
     }
     $this->coreRegistry->register('current_article', $article);
     $resultPage = $this->resultPageFactory->create();
     $title = $article->getMetaTitle() ?: $article->getName();
     $resultPage->getConfig()->getTitle()->set($title);
     $resultPage->getConfig()->setDescription($article->getMetaDescription());
     $resultPage->getConfig()->setKeywords($article->getMetaKeywords());
     if ($this->scopeConfig->isSetFlag(self::BREADCRUMBS_CONFIG_PATH, ScopeInterface::SCOPE_STORE)) {
         /** @var \Magento\Theme\Block\Html\Breadcrumbs $breadcrumbsBlock */
         $breadcrumbsBlock = $resultPage->getLayout()->getBlock('breadcrumbs');
         if ($breadcrumbsBlock) {
             $breadcrumbsBlock->addCrumb('home', ['label' => __('Home'), 'link' => $this->_url->getUrl('')]);
             $breadcrumbsBlock->addCrumb('articles', ['label' => __('Articles'), 'link' => $this->urlModel->getListUrl()]);
             $breadcrumbsBlock->addCrumb('article-' . $article->getId(), ['label' => $article->getName()]);
         }
     }
     return $resultPage;
 }
예제 #3
0
파일: Index.php 프로젝트: vasuscoin/brand
 /**
  * Default customer account page
  *
  * @return \Magento\Framework\View\Result\Page
  */
 public function execute()
 {
     if (!$this->_brandHelper->getConfig('general_settings/enable')) {
         return $this->resultForwardFactory->create()->forward('noroute');
     }
     /** @var \Magento\Framework\View\Result\Page $resultPage */
     $page = $this->resultPageFactory->create();
     return $page;
 }
예제 #4
0
 /**
  * View CMS page action
  *
  * @return \Magento\Framework\Controller\ResultInterface
  */
 public function execute()
 {
     $pageId = $this->getRequest()->getParam('page_id', $this->getRequest()->getParam('id', false));
     $resultPage = $this->_objectManager->get('Magento\\Cms\\Helper\\Page')->prepareResultPage($this, $pageId);
     if (!$resultPage) {
         $resultForward = $this->resultForwardFactory->create();
         return $resultForward->forward('noroute');
     }
     return $resultPage;
 }
 /**
  * Blog Index, shows a list of recent blog posts.
  *
  * @return \Magento\Framework\View\Result\PageFactory
  */
 public function execute()
 {
     $post_id = $this->getRequest()->getParam('post_id', $this->getRequest()->getParam('id', false));
     /** @var \Ashsmith\Blog\Helper\Post $post_helper */
     $post_helper = $this->_objectManager->get('Ashsmith\\Blog\\Helper\\Post');
     $result_page = $post_helper->prepareResultPost($this, $post_id);
     if (!$result_page) {
         $resultForward = $this->resultForwardFactory->create();
         return $resultForward->forward('noroute');
     }
     return $result_page;
 }
예제 #6
0
 /**
  * Renders CMS Home page
  *
  * @param string|null $coreRoute
  * @return \Magento\Framework\Controller\Result\Forward
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute($coreRoute = null)
 {
     $pageId = $this->_objectManager->get('Magento\\Framework\\App\\Config\\ScopeConfigInterface')->getValue(\Magento\Cms\Helper\Page::XML_PATH_HOME_PAGE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
     $resultPage = $this->_objectManager->get('Magento\\Cms\\Helper\\Page')->prepareResultPage($this, $pageId);
     if (!$resultPage) {
         /** @var \Magento\Framework\Controller\Result\Forward $resultForward */
         $resultForward = $this->resultForwardFactory->create();
         $resultForward->forward('defaultIndex');
         return $resultForward;
     }
     return $resultPage;
 }
예제 #7
0
파일: Index.php 프로젝트: swnsma/practice
 public function execute()
 {
     $id = $this->getRequest()->getParam('post_id', $this->getRequest()->getParam('id', false));
     /** @var \ISM\Blog\Helper\Post $helper */
     $helper = $this->_objectManager->get('ISM\\Blog\\Helper\\Post');
     $result = $helper->prepareResultPost($this, $id);
     if (!$result) {
         /** @var \Magento\Framework\Controller\Result\Forward $resultForward */
         $resultForward = $this->_forwardFactory->create();
         return $resultForward->forward('noroute');
     }
     return $result;
 }
예제 #8
0
 protected function setUp()
 {
     $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManagerInterface');
     $responseMock = $this->getMock('Magento\\Framework\\App\\Response\\Http', [], [], '', false);
     $this->resultPageMock = $this->getMockBuilder('\\Magento\\Framework\\View\\Result\\Page')->disableOriginalConstructor()->getMock();
     $this->forwardFactoryMock = $this->getMockBuilder('\\Magento\\Framework\\Controller\\Result\\ForwardFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $this->forwardMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Forward')->disableOriginalConstructor()->getMock();
     $this->forwardFactoryMock->expects($this->any())->method('create')->willReturn($this->forwardMock);
     $this->requestMock = $this->getMock('Magento\\Framework\\App\\Request\\Http', [], [], '', false);
     $this->cmsHelperMock = $this->getMock('Magento\\Cms\\Helper\\Page', [], [], '', false);
     $objectManagerMock->expects($this->once())->method('get')->willReturn($this->cmsHelperMock);
     $this->controller = $helper->getObject('Magento\\Cms\\Controller\\Page\\View', ['response' => $responseMock, 'objectManager' => $objectManagerMock, 'request' => $this->requestMock, 'resultForwardFactory' => $this->forwardFactoryMock]);
 }
예제 #9
0
 /**
  * View product gallery action
  *
  * @return \Magento\Framework\Controller\ResultInterface
  */
 public function execute()
 {
     $result = null;
     if (!$this->_initProduct()) {
         $store = $this->getRequest()->getQuery('store');
         if (isset($store) && !$this->getResponse()->isRedirect()) {
             $result = $this->resultRedirectFactory->create();
             $result->setPath('');
         } elseif (!$this->getResponse()->isRedirect()) {
             $result = $this->resultForwardFactory->create();
             $result->forward('noroute');
         }
     }
     return $result ?: $this->resultPageFactory->create();
 }
예제 #10
0
파일: View.php 프로젝트: vasuscoin/brand
 /**
  * Default customer account page
  *
  * @return \Magento\Framework\View\Result\Page
  */
 public function execute()
 {
     if (!$this->_brandHelper->getConfig('general_settings/enable')) {
         return $this->resultForwardFactory->create()->forward('noroute');
     }
     $brand = $this->_initBrand();
     if ($brand) {
         $this->layerResolver->create('brand');
         /** @var \Magento\Framework\View\Result\Page $resultPage */
         $page = $this->resultPageFactory->create();
         // apply custom layout (page) template once the blocks are generated
         if ($brand->getPageLayout()) {
             $page->getConfig()->setPageLayout($brand->getPageLayout());
         }
         $page->addHandle(['type' => 'VES_BRAND_' . $brand->getId()]);
         if (($layoutUpdate = $brand->getLayoutUpdateXml()) && trim($layoutUpdate) != '') {
             $page->addUpdate($layoutUpdate);
         }
         /*$collectionSize = $brand->getProductCollection()->getSize();
           if($collectionSize){
               $page->addHandle(['type' => 'vesbrand_brand_layered']);
           }*/
         $page->getConfig()->addBodyClass('page-products')->addBodyClass('brand-' . $brand->getUrlKey());
         return $page;
     } elseif (!$this->getResponse()->isRedirect()) {
         return $this->resultForwardFactory->create()->forward('noroute');
     }
 }
예제 #11
0
 public function execute()
 {
     if (($json = $this->getRequest()->getParam('json')) && $json == 1) {
         return parent::execute();
     }
     $orderId = $this->getRequest()->getParam('orderID');
     $order = $this->_orderFactory->create();
     $order->load($orderId);
     if (!$order->getId()) {
         $resultForward = $this->_resultForwardFactory->create();
         return $resultForward->forward('noroute');
     }
     $this->_registry->register('order', $order);
     $resultPage = $this->_resultPageFactory->create();
     $resultPage->getConfig()->getTitle()->set(__('Order Info'));
     return $resultPage;
 }
예제 #12
0
 /**
  * @param RequestInterface $request
  * @return bool|\Magento\Framework\Controller\Result\Forward|\Magento\Framework\Controller\Result\Redirect
  */
 public function load(RequestInterface $request)
 {
     $orderId = (int) $request->getParam('order_id');
     if (!$orderId) {
         /** @var \Magento\Framework\Controller\Result\Forward $resultForward */
         $resultForward = $this->resultForwardFactory->create();
         return $resultForward->forward('noroute');
     }
     $order = $this->orderFactory->create()->load($orderId);
     if ($this->orderAuthorization->canView($order)) {
         $this->registry->register('current_order', $order);
         return true;
     }
     /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
     $resultRedirect = $this->redirectFactory->create();
     return $resultRedirect->setUrl($this->url->getUrl('*/*/history'));
 }
예제 #13
0
 protected function setUp()
 {
     $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManagerInterface');
     $responseMock = $this->getMock('Magento\\Framework\\App\\Response\\Http', [], [], '', false);
     $this->resultPageMock = $this->getMockBuilder('\\Magento\\Framework\\View\\Result\\Page')->disableOriginalConstructor()->getMock();
     $this->forwardFactoryMock = $this->getMockBuilder('\\Magento\\Framework\\Controller\\Result\\ForwardFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $this->forwardMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Forward')->disableOriginalConstructor()->getMock();
     $this->forwardFactoryMock->expects($this->any())->method('create')->willReturn($this->forwardMock);
     $scopeConfigMock = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface');
     $this->_requestMock = $this->getMock('Magento\\Framework\\App\\Request\\Http', [], [], '', false);
     $this->_cmsHelperMock = $this->getMock('Magento\\Cms\\Helper\\Page', [], [], '', false);
     $valueMap = [['Magento\\Framework\\App\\Config\\ScopeConfigInterface', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $scopeConfigMock], ['Magento\\Cms\\Helper\\Page', $this->_cmsHelperMock]];
     $objectManagerMock->expects($this->any())->method('get')->will($this->returnValueMap($valueMap));
     $scopeConfigMock->expects($this->once())->method('getValue')->with(\Magento\Cms\Helper\Page::XML_PATH_NO_ROUTE_PAGE)->will($this->returnValue('pageId'));
     $this->_controller = $helper->getObject('Magento\\Cms\\Controller\\Noroute\\Index', ['response' => $responseMock, 'objectManager' => $objectManagerMock, 'request' => $this->_requestMock, 'resultForwardFactory' => $this->forwardFactoryMock]);
 }
예제 #14
0
파일: Index.php 프로젝트: tingyeeh/magento2
 /**
  * Render CMS 404 Not found page
  *
  * @return \Magento\Framework\Controller\ResultInterface
  */
 public function execute()
 {
     $pageId = $this->_objectManager->get('Magento\\Framework\\App\\Config\\ScopeConfigInterface', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)->getValue(\Magento\Cms\Helper\Page::XML_PATH_NO_ROUTE_PAGE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
     /** @var \Magento\Cms\Helper\Page $pageHelper */
     $pageHelper = $this->_objectManager->get('Magento\\Cms\\Helper\\Page');
     $resultPage = $pageHelper->prepareResultPage($this, $pageId);
     if ($resultPage) {
         $resultPage->setStatusHeader(404, '1.1', 'Not Found');
         $resultPage->setHeader('Status', '404 File not found');
         return $resultPage;
     } else {
         /** @var \Magento\Framework\Controller\Result\Forward $resultForward */
         $resultForward = $this->resultForwardFactory->create();
         $resultForward->setController('index');
         $resultForward->forward('defaultNoRoute');
         return $resultForward;
     }
 }
예제 #15
0
    /**
     * Custom options download action
     *
     * @return void|\Magento\Framework\Controller\Result\Forward
     *
     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
     */
    public function executeInternal()
    {
        $quoteItemOptionId = $this->getRequest()->getParam('id');
        /** @var $option \Magento\Quote\Model\Quote\Item\Option */
        $option = $this->_objectManager->create('Magento\Quote\Model\Quote\Item\Option')->load($quoteItemOptionId);
        /** @var \Magento\Framework\Controller\Result\Forward $resultForward */
        $resultForward = $this->resultForwardFactory->create();

        if (!$option->getId()) {
            return $resultForward->forward('noroute');
        }

        $optionId = null;
        if (strpos($option->getCode(), AbstractType::OPTION_PREFIX) === 0) {
            $optionId = str_replace(AbstractType::OPTION_PREFIX, '', $option->getCode());
            if ((int)$optionId != $optionId) {
                $optionId = null;
            }
        }
        $productOption = null;
        if ($optionId) {
            /** @var $productOption \Magento\Catalog\Model\Product\Option */
            $productOption = $this->_objectManager->create('Magento\Catalog\Model\Product\Option')->load($optionId);
        }
        if (!$productOption ||
            !$productOption->getId() ||
            $productOption->getProductId() != $option->getProductId() ||
            $productOption->getType() != 'file'
        ) {
            return $resultForward->forward('noroute');
        }

        try {
            $info = $this->unserialize->unserialize($option->getValue());
            if ($this->getRequest()->getParam('key') != $info['secret_key']) {
                return $resultForward->forward('noroute');
            }
            $this->download->downloadFile($info);
        } catch (\Exception $e) {
            return $resultForward->forward('noroute');
        }
        $this->endExecute();
    }
예제 #16
0
 public function execute()
 {
     /**
      * @var $client \Orba\Payupl\Model\Client
      */
     $request = $this->context->getRequest();
     try {
         $client = $this->clientFactory->create();
         $response = $client->orderConsumeNotification($request);
         $clientOrderHelper = $client->getOrderHelper();
         if ($clientOrderHelper->canProcessNotification($response['payuplOrderId'])) {
             return $clientOrderHelper->processNotification($response['payuplOrderId'], $response['status'], $response['amount']);
         }
     } catch (LocalizedException $e) {
         $this->logger->critical($e);
     }
     /**
      * @var $resultForward \Magento\Framework\Controller\Result\Forward
      */
     $resultForward = $this->resultForwardFactory->create();
     $resultForward->forward('noroute');
     return $resultForward;
 }
예제 #17
0
파일: View.php 프로젝트: vasuscoin/brand
 /**
  * Default customer account page
  *
  * @return \Magento\Framework\View\Result\Page
  */
 public function execute()
 {
     if (!$this->_brandHelper->getConfig('general_settings/enable')) {
         return $this->resultForwardFactory->create()->forward('noroute');
     }
     $group = $this->_initGroup();
     if ($group) {
         $page = $this->resultPageFactory->create();
         $page->getConfig()->addBodyClass('group-' . $group->getUrlKey());
         return $page;
     } elseif (!$this->getResponse()->isRedirect()) {
         return $this->resultForwardFactory->create()->forward('noroute');
     }
 }
예제 #18
0
 /**
  * Category view action
  *
  * @return \Magento\Framework\Controller\ResultInterface
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function execute()
 {
     if ($this->_request->getParam(\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED)) {
         return $this->resultRedirectFactory->create()->setUrl($this->_redirect->getRedirectUrl());
     }
     $category = $this->_initCategory();
     if ($category) {
         $this->layerResolver->create(Resolver::CATALOG_LAYER_CATEGORY);
         $settings = $this->_catalogDesign->getDesignSettings($category);
         // apply custom design
         if ($settings->getCustomDesign()) {
             $this->_catalogDesign->applyCustomDesign($settings->getCustomDesign());
         }
         $this->_catalogSession->setLastViewedCategoryId($category->getId());
         $page = $this->resultPageFactory->create();
         // apply custom layout (page) template once the blocks are generated
         if ($settings->getPageLayout()) {
             $page->getConfig()->setPageLayout($settings->getPageLayout());
         }
         $hasChildren = $category->hasChildren();
         if ($category->getIsAnchor()) {
             $type = $hasChildren ? 'layered' : 'layered_without_children';
         } else {
             $type = $hasChildren ? 'default' : 'default_without_children';
         }
         if (!$hasChildren) {
             // Two levels removed from parent.  Need to add default page type.
             $parentType = strtok($type, '_');
             $page->addPageLayoutHandles(['type' => $parentType]);
         }
         $page->addPageLayoutHandles(['type' => $type, 'id' => $category->getId()]);
         // apply custom layout update once layout is loaded
         $layoutUpdates = $settings->getLayoutUpdates();
         if ($layoutUpdates && is_array($layoutUpdates)) {
             foreach ($layoutUpdates as $layoutUpdate) {
                 $page->addUpdate($layoutUpdate);
                 $page->addPageLayoutHandles(['layout_update' => md5($layoutUpdate)]);
             }
         }
         $page->getConfig()->addBodyClass('page-products')->addBodyClass('categorypath-' . $this->categoryUrlPathGenerator->getUrlPath($category))->addBodyClass('category-' . $category->getUrlKey());
         return $page;
     } elseif (!$this->getResponse()->isRedirect()) {
         return $this->resultForwardFactory->create()->forward('noroute');
     }
 }
예제 #19
0
 /**
  * Product view action
  *
  * @return \Magento\Framework\Controller\Result\Forward|\Magento\Framework\Controller\Result\Redirect
  */
 public function execute()
 {
     // Get initial data from request
     $categoryId = (int) $this->getRequest()->getParam('category', false);
     $productId = (int) $this->getRequest()->getParam('id');
     $specifyOptions = $this->getRequest()->getParam('options');
     if ($this->getRequest()->isPost() && $this->getRequest()->getParam(self::PARAM_NAME_URL_ENCODED)) {
         $product = $this->_initProduct();
         if (!$product) {
             return $this->noProductRedirect();
         }
         if ($specifyOptions) {
             $notice = $product->getTypeInstance()->getSpecifyOptionMessage();
             $this->messageManager->addNotice($notice);
         }
         if ($this->getRequest()->isAjax()) {
             $this->getResponse()->representJson($this->_objectManager->get('Magento\\Framework\\Json\\Helper\\Data')->jsonEncode(['backUrl' => $this->_redirect->getRedirectUrl()]));
             return;
         }
         $resultRedirect = $this->resultRedirectFactory->create();
         $resultRedirect->setRefererOrBaseUrl();
         return $resultRedirect;
     }
     // Prepare helper and params
     $params = new \Magento\Framework\DataObject();
     $params->setCategoryId($categoryId);
     $params->setSpecifyOptions($specifyOptions);
     // Render page
     try {
         $page = $this->resultPageFactory->create(false, ['isIsolated' => true]);
         $this->viewHelper->prepareAndRender($page, $productId, $this, $params);
         return $page;
     } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
         return $this->noProductRedirect();
     } catch (\Exception $e) {
         $this->_objectManager->get('Psr\\Log\\LoggerInterface')->critical($e);
         $resultForward = $this->resultForwardFactory->create();
         $resultForward->forward('noroute');
         return $resultForward;
     }
 }
 public function execute()
 {
     $error = false;
     $output = '';
     $config = $this->getRequest()->getParam('config');
     try {
         if (empty($config['key'])) {
             throw new \Exception('Key is missing');
         } else {
             $configKey = $config['key'];
         }
         $scopeList = array('default', 'websites', 'stores', 'auto');
         if (empty($config['scope']) or !in_array($config['scope'], $scopeList)) {
             throw new \Exception('Scope is missing');
         } else {
             $configScope = $config['scope'];
             if ($configScope == 'auto') {
                 switch ($configKey) {
                     case 'hints':
                     case 'translate':
                         $configScope = 'stores';
                         break;
                     default:
                         throw new \Exception('Scope auto is unrecognized');
                         break;
                 }
             }
         }
         if (empty($config['value'])) {
             $configValue = 1;
         } else {
             $configValue = $config['value'];
         }
         switch ($configScope) {
             case 'stores':
                 $configScopeId = $this->_storeManager->getStore()->getId();
                 break;
             case 'websites':
                 $configScopeId = $this->_storeManager->getWebsite()->getId();
                 break;
             default:
                 $configScopeId = 0;
                 break;
         }
         switch ($configKey) {
             case 'hints':
                 $configValue = $this->_qdbHelper->getConfig('dev/debug/template_hints', $configScope, $configScopeId) ? 0 : 1;
                 $this->_resourceConfig->saveConfig('dev/debug/template_hints', $configValue, $configScope, $configScopeId);
                 $this->_resourceConfig->saveConfig('dev/debug/template_hints_blocks', $configValue, $configScope, $configScopeId);
                 $output = "Hints set " . ($configValue ? 'On' : 'Off');
                 break;
             case 'translate':
                 $configValue = $this->_qdbHelper->getConfig('dev/translate_inline/active', $configScope, $configScopeId) ? 0 : 1;
                 $this->_resourceConfig->saveConfig('dev/translate_inline/active', $configValue, $configScope, $configScopeId);
                 $output = "Translate set " . ($configValue ? 'On' : 'Off');
                 break;
             default:
                 break;
         }
         if ($output) {
             $this->_qdbHelper->setControllerMessage($output);
         }
     } catch (\Exception $e) {
         $output = $e->getMessage();
         $error = true;
     }
     if (!$error) {
         /** @var \Magento\Framework\Controller\Result\Forward $resultForward */
         $resultForward = $this->_resultForwardFactory->create();
         $resultForward->forward('cache');
         return $resultForward;
     } else {
         $this->_view->loadLayout();
         $resultRaw = $this->_resultRawFactory->create();
         return $resultRaw->setContents($output);
     }
 }