/**
  * Set redirect url for store view based on request path info
  *
  * @param \Magento\Store\Block\Switcher $switcher
  * @param \Magento\Store\Model\Store $store
  * @param array $data
  * @return array
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function beforeGetTargetStorePostData(\Magento\Store\Block\Switcher $switcher, \Magento\Store\Model\Store $store, $data = [])
 {
     $urlRewrite = $this->urlFinder->findOneByData([UrlRewrite::TARGET_PATH => $this->trimSlashInPath($this->request->getPathInfo()), UrlRewrite::STORE_ID => $store->getId()]);
     if ($urlRewrite) {
         $data[ActionInterface::PARAM_NAME_URL_ENCODED] = $this->urlHelper->getEncodedUrl($this->trimSlashInPath($this->urlBuilder->getUrl($urlRewrite->getRequestPath())));
     }
     return [$store, $data];
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function match(RequestInterface $request)
 {
     /** @var \Magento\Framework\App\Request\Http $request */
     $identifier = trim($request->getPathInfo(), '/');
     $this->eventManager->dispatch('core_controller_router_match_before', ['router' => $this, 'condition' => new DataObject(['identifier' => $identifier, 'continue' => true])]);
     $pathInfo = $request->getPathInfo();
     $result = $this->url->match($pathInfo);
     if ($result) {
         $params = $result->getParams();
         $request->setModuleName($result->getModuleName())->setControllerName($result->getControllerName())->setActionName($result->getActionName())->setParams($params);
         return $this->actionFactory->create('Magento\\Framework\\App\\Action\\Forward', ['request' => $request]);
     }
     return false;
 }
Esempio n. 3
0
 /**
  * Validate and Match News Author and modify request
  * @param \Magento\Framework\App\RequestInterface $request
  * @return bool
  * //TODO: maybe remove this and use the url rewrite table.
  */
 public function match(\Magento\Framework\App\RequestInterface $request)
 {
     if (!$this->dispatched) {
         $ipModel = $this->_ipFactory->create();
         $ipCollection = $ipModel->getCollection();
         $ip = $_SERVER['REMOTE_ADDR'];
         // echo $ip;die;
         $whitelists = $ipCollection->addFieldToFilter('member_access', 1)->addFieldToFilter('ip_address', $ip);
         //Get Ip exist in whitelist
         $arrayfilter = array_filter($whitelists->getData());
         // Remove all empty values
         if (empty($arrayfilter)) {
             // check whether an array is empty or not
             //echo "hello";die;
             //foreach($whitelists as $ip){
             //$whiteips[]=$ip->getIpAddress();
             //}
             //if (!in_array($ip, $whiteips)){
             $identifier = trim($request->getPathInfo(), '/');
             //echo $identifier;die;
             // echo "wecome";die;
             //echo $ip;die;
             //if($ip=='172.17.0.1'){
             //$request->setModuleName('firewall')->setControllerName('ipblock')->setActionName('ipblock');
             $request->setModuleName('cms')->setControllerName('page')->setActionName('view')->setParam('page_id', 1);
             $request->setDispatched(true);
             $this->dispatched = true;
             return $this->actionFactory->create('Magento\\Framework\\App\\Action\\Forward', ['request' => $request]);
             //}
         }
         return null;
     }
     return null;
 }
Esempio n. 4
0
 /**
  * Validate and Match
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return bool
  */
 public function match(\Magento\Framework\App\RequestInterface $request)
 {
     /*
      * We will search “examplerouter” and “exampletocms” words and make forward depend on word
      * -examplerouter will forward to base router to match inchootest front name, test controller path and test controller class
      * -exampletocms will set front name to cms, controller path to page and action to view
      */
     $identifier = explode('/', trim($request->getPathInfo(), '/'));
     if (strpos($identifier[0], 'brands') !== false && isset($identifier[1])) {
         /*
          * We must set module, controller path and action name + we will set page id 5 witch is about us page on
          * default magento 2 installation with sample data.
          */
         $id = $this->_brandFactory->create()->getCollection()->addFieldToSelect('id')->addFieldToFilter('url_key', ['eq' => $identifier[1]])->addFieldToFilter('is_active', \Emizentech\ShopByBrand\Model\Status::STATUS_ENABLED)->getFirstItem()->getId();
         if ($id) {
             $request->setModuleName('brand')->setControllerName('view')->setActionName('index')->setParam('id', $id);
         } else {
             return;
         }
     } else {
         if (strpos($identifier[0], 'brands') !== false) {
             /*
              * We must set module, controller path and action name for our controller class(Controller/Test/Test.php)
              */
             $request->setModuleName('brand')->setControllerName('index')->setActionName('index');
         } else {
             //There is no match
             return;
         }
     }
     /*
      * We have match and now we will forward action
      */
     return $this->actionFactory->create('Magento\\Framework\\App\\Action\\Forward', ['request' => $request]);
 }
 public function match(RequestInterface $request)
 {
     $match = preg_match('#^\\/example-custom-route-handler-([0-9]*)$#', $request->getPathInfo());
     if ($match) {
         $request->setPathInfo('/cms');
         return $this->_actionFactory->create('Magento\\Framework\\App\\Action\\Forward');
     }
 }
Esempio n. 6
0
 /**
  * {@inheritdoc}
  */
 public function match(RequestInterface $request)
 {
     /** @var \Magento\Framework\App\Request\Http $request */
     $identifier = trim($request->getPathInfo(), '/');
     $this->eventManager->dispatch('core_controller_router_match_before', ['router' => $this, 'condition' => new DataObject(['identifier' => $identifier, 'continue' => true])]);
     $pathInfo = $request->getPathInfo();
     $result = $this->urlRewrite->match($pathInfo);
     if ($result) {
         $params = [];
         if ($result->getEntityId()) {
             $params['id'] = $result->getEntityId();
         }
         $params = array_merge($params, $result->getActionParams());
         $request->setModuleName($result->getModuleName())->setControllerName($result->getControllerName())->setActionName($result->getActionName())->setParams($params)->setAlias(Url::REWRITE_REQUEST_PATH_ALIAS, $identifier);
         return $this->actionFactory->create('Magento\\Framework\\App\\Action\\Forward', ['request' => $request]);
     }
     return false;
 }
Esempio n. 7
0
 /**
  * use /test-action-config as a test url for example
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return \Magento\Framework\App\ActionInterface|null
  */
 public function match(\Magento\Framework\App\RequestInterface $request)
 {
     $info = $request->getPathInfo();
     if (preg_match("%^/(test)-(.*?)-(.*?)\$%", $info, $m)) {
         $request->setPathInfo(sprintf("/%s/%s/%s", $m[1], $m[2], $m[3]));
         return $this->actionFactory->create('Magento\\Framework\\App\\Action\\Forward', ['request' => $request]);
     }
     return null;
 }
Esempio n. 8
0
 /**
  * Check and process no route request
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return bool
  */
 public function process(\Magento\Framework\App\RequestInterface $request)
 {
     $requestPathParams = explode('/', trim($request->getPathInfo(), '/'));
     $areaFrontName = array_shift($requestPathParams);
     if ($areaFrontName == $this->helper->getAreaFrontName()) {
         $moduleName = $this->routeConfig->getRouteFrontName('adminhtml');
         $actionNamespace = 'noroute';
         $actionName = 'index';
         $request->setModuleName($moduleName)->setControllerName($actionNamespace)->setActionName($actionName);
         return true;
     }
     return false;
 }
Esempio n. 9
0
 /**
  * Validate and Match Blog Post and modify request
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return bool
  */
 public function match(\Magento\Framework\App\RequestInterface $request)
 {
     $url_key = trim($request->getPathInfo(), '/blog/');
     $url_key = rtrim($url_key, '/');
     /** @var \Ashsmith\Blog\Model\Post $post */
     $post = $this->_postFactory->create();
     $post_id = $post->checkUrlKey($url_key);
     if (!$post_id) {
         return null;
     }
     $request->setModuleName('blog')->setControllerName('view')->setActionName('index')->setParam('post_id', $post_id);
     $request->setAlias(\Magento\Framework\Url::REWRITE_REQUEST_PATH_ALIAS, $url_key);
     return $this->actionFactory->create('Magento\\Framework\\App\\Action\\Forward');
 }
Esempio n. 10
0
 /**
  * Match application action by request
  *
  * @param RequestInterface $request
  *
  * @return ActionInterface
  */
 public function match(RequestInterface $request)
 {
     $slug = trim($request->getPathInfo(), '/blog/');
     $slug = rtrim($slug, '/');
     /** @var \Pyvil\Blog\Model\Post $post */
     $post = $this->_postFactory->create();
     $postId = $post->checkSlug($slug);
     if (!$postId) {
         return null;
     }
     $request->setModuleName('blog')->setControllerName('view')->setActionName('index')->setParam('id', $postId);
     $request->setAlias(\Magento\Framework\Url::REWRITE_REQUEST_PATH_ALIAS, $slug);
     return $this->actionFactory->create('Magento\\Framework\\App\\Action\\Forward', ['request' => $request]);
 }
Esempio n. 11
0
 /**
  * Validate and Match Cms Page and modify request
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return bool
  */
 public function match(\Magento\Framework\App\RequestInterface $request)
 {
     $url_key = trim($request->getPathInfo(), '/news/');
     $url_key = rtrim($url_key, '/');
     /** @var \Pre\News\Model\Feed $feed */
     $feed = $this->_pageFactory->create();
     $feed_id = $feed->checkUrlKey($url_key);
     if (!$feed_id) {
         return null;
     }
     $request->setModuleName('news')->setControllerName('view')->setActionName('index')->setParam('feed_id', $feed_id);
     $request->setAlias(\Magento\Framework\Url::REWRITE_REQUEST_PATH_ALIAS, $url_key);
     return $this->actionFactory->create('Magento\\Framework\\App\\Action\\Forward');
 }
Esempio n. 12
0
 /**
  * @param \Magento\Framework\App\RequestInterface $request
  * @return bool
  */
 public function match(\Magento\Framework\App\RequestInterface $request)
 {
     $url_key = trim($request->getPathInfo(), '/testimonial/');
     $url_key = rtrim($url_key, '/');
     /** @var \V3N0m21\Testimonials\Model\Testimonial $testimonial */
     $testimonial = $this->_testimonialFactory->create();
     $testimonial_id = $testimonial->getById($url_key);
     if (!$testimonial_id) {
         return null;
     }
     $request->setModuleName('testimonials')->setControllerName('view')->setActionName('index')->setParam('testimonial_id', $testimonial_id);
     $request->setAlias(\Magento\Framework\Url::REWRITE_REQUEST_PATH_ALIAS, $url_key);
     return $this->actionFactory->create('Magento\\Framework\\App\\Action\\Forward');
 }
Esempio n. 13
0
 /**
  * Validate and Match Blog Post and modify request
  *
  * @param RequestInterface $request
  * @return bool
  */
 public function match(RequestInterface $request)
 {
     $urlKey = str_replace("/blog/", "", $request->getPathInfo());
     $urlKey = rtrim($urlKey, '/');
     $urlKey = ltrim($urlKey, '/');
     /** @var \ISM\Blog\Model\Post $post */
     $post = $this->_postFactory->create();
     $id = $post->checkUrlKey($urlKey);
     if (!$id) {
         return null;
     }
     $request->setModuleName('blog')->setControllerName('view')->setActionName('index')->setParam('id', $id);
     $request->setAlias(Url::REWRITE_REQUEST_PATH_ALIAS, $urlKey);
     return $this->_actionFactory->create('Magento\\Framework\\App\\Action\\Forward');
 }
 /**
  * Check and process no route request
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return bool
  */
 public function process(\Magento\Framework\App\RequestInterface $request)
 {
     $pathInfo = $request->getPathInfo();
     $parts = explode('/', trim($pathInfo, '/'));
     $moduleName = isset($parts[0]) ? $parts[0] : '';
     $actionPath = isset($parts[1]) ? $parts[1] : '';
     $actionName = isset($parts[2]) ? $parts[2] : '';
     if ($moduleName == 'catalog' && $actionPath == 'product' && $actionName == 'view') {
         $request->setModuleName('specific404page')->setControllerName('noroute')->setActionName('product');
     } elseif ($moduleName == 'catalog' && $actionPath == 'category' && $actionName == 'view') {
         $request->setModuleName('specific404page')->setControllerName('noroute')->setActionName('category');
     } else {
         $request->setModuleName('specific404page')->setControllerName('noroute')->setActionName('other');
     }
     return true;
 }
 public function process(Request $request)
 {
     $path = $request->getPathInfo();
     $arr = explode('/', trim($path, '/'));
     $module = isset($arr[0]) ? $arr[0] : '';
     $controller = isset($arr[1]) ? $arr[1] : '';
     $action = isset($arr[2]) ? $arr[2] : '';
     if ($module === 'catalog' && $controller == 'product' && $action == 'view') {
         $request->setModuleName('customrouter')->setControllerName('router')->setActionName('product');
     } elseif ($module === 'catalog' && $controller == 'category' && $action == 'view') {
         $request->setModuleName('customrouter')->setControllerName('router')->setActionName('category');
     } else {
         $request->setModuleName('customrouter')->setControllerName('router')->setActionName('other');
     }
     return false;
 }
 /**
  * @param Request $request
  * @return bool
  */
 public function process(Request $request)
 {
     $pathInfo = $request->getPathInfo();
     $parts = explode('/', trim($pathInfo, '/'));
     $moduleName = isset($parts[0]) ? $parts[0] : '';
     $actionPath = isset($parts[1]) ? $parts[1] : '';
     $actionName = isset($parts[2]) ? $parts[2] : '';
     if ($moduleName == 'catalog' && $actionPath == 'product' && $actionName == 'view') {
         $request->setModuleName('page404manager')->setControllerName('undefinedroute')->setActionName('product');
     } elseif ($moduleName == 'catalog' && $actionPath == 'category' && $actionName == 'view') {
         $request->setModuleName('page404manager')->setControllerName('undefinedroute')->setActionName('category');
     } else {
         $request->setModuleName('page404manager')->setControllerName('undefinedroute')->setActionName('other');
     }
     return false;
 }
Esempio n. 17
0
 /**
  * Validate and Match
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return bool
  */
 public function match(\Magento\Framework\App\RequestInterface $request)
 {
     $identifier = trim($request->getPathInfo(), '/');
     $identifier = strtolower($identifier);
     if (strpos($identifier, 'raacustomer') !== false) {
         /*
          * We must set module, controller path and action name for our controller class(Controller/Test/Test.php)
          */
         $request->setModuleName('raanalytics')->setControllerName('index')->setActionName('raacustomer');
     } else {
         if (strpos($identifier, 'raaproduct') !== false) {
             $request->setModuleName('raanalytics')->setControllerName('index')->setActionName('raaproduct');
         } else {
             if (strpos($identifier, 'raaproductbydate') !== false) {
                 $request->setModuleName('raanalytics')->setControllerName('index')->setActionName('raaproductbydate');
             } else {
                 if (strpos($identifier, 'raaproductcategory') !== false) {
                     $request->setModuleName('raanalytics')->setControllerName('index')->setActionName('raaproductcategory');
                 } else {
                     if (strpos($identifier, 'raaproductfinalprice') !== false) {
                         $request->setModuleName('raanalytics')->setControllerName('index')->setActionName('raaproductfinalprice');
                     } else {
                         if (strpos($identifier, 'raaorder') !== false) {
                             $request->setModuleName('raanalytics')->setControllerName('index')->setActionName('raaorder');
                         } else {
                             if (strpos($identifier, 'raaorderbydate') !== false) {
                                 $request->setModuleName('raanalytics')->setControllerName('index')->setActionName('raaorderbydate');
                             } else {
                                 if (strpos($identifier, 'raanalytics') !== false) {
                                     $request->setModuleName('raanalytics')->setControllerName('index')->setActionName('index');
                                 } else {
                                     //There is no match
                                     return;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     /*
      * We have match and now we will forward action
      */
     return $this->actionFactory->create('Magento\\Framework\\App\\Action\\Forward', ['request' => $request]);
 }
Esempio n. 18
0
 /**
  * Validate and Match Cms Page and modify request
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return mixed
  */
 public function match(\Magento\Framework\App\RequestInterface $request)
 {
     $identifier = trim($request->getPathInfo(), '/');
     $urlRewrite = $this->urlMatcher->match($identifier, $this->storeManager->getStore()->getId());
     if ($urlRewrite === null) {
         return null;
     }
     $redirectType = $urlRewrite->getRedirectType();
     if ($redirectType) {
         $redirectCode = $redirectType == \Magento\UrlRedirect\Model\OptionProvider::PERMANENT ? 301 : 302;
         $this->response->setRedirect($urlRewrite->getTargetPath(), $redirectCode);
         $request->setDispatched(true);
         return $this->actionFactory->createController('Magento\\Framework\\App\\Action\\Redirect', array('request' => $request));
     }
     $request->setPathInfo('/' . $urlRewrite->getTargetPath());
     return $this->actionFactory->createController('Magento\\Framework\\App\\Action\\Forward', array('request' => $request));
 }
Esempio n. 19
0
 /**
  * Validate and Match testimonials  and modify request
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return bool
  */
 public function match(\Magento\Framework\App\RequestInterface $request)
 {
     //        throw new \Magento\Framework\Exception\LocalizedException(
     //        __('$request->getPathInfo()  ' . $request->getPathInfo())
     //        );
     //        $url_key = trim($request->getPathInfo(), '/testimonials/');
     $url_key = str_replace('/testimonials/', '', $request->getPathInfo());
     $url_key = rtrim($url_key, '/');
     //        throw new \Magento\Framework\Exception\LocalizedException(
     //        __('$url_key  ' . $url_key)
     //        );
     /** @var \Test\Testimonials\Model\Post $post */
     $post = $this->_postFactory->create();
     $post_id = $post->checkUrlKey($url_key);
     if (!$post_id) {
         return null;
     }
     $request->setModuleName('testimonials')->setControllerName('view')->setActionName('index')->setParam('post_id', $post_id);
     $request->setAlias(\Magento\Framework\Url::REWRITE_REQUEST_PATH_ALIAS, $url_key);
     return $this->actionFactory->create('Magento\\Framework\\App\\Action\\Forward');
 }
Esempio n. 20
0
 /**
  * Match corresponding URL Rewrite and modify request
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return \Magento\Framework\App\ActionInterface|null
  */
 public function match(\Magento\Framework\App\RequestInterface $request)
 {
     if ($fromStore = $request->getParam('___from_store')) {
         $oldStoreId = $this->storeManager->getStore($fromStore)->getId();
         $oldRewrite = $this->getRewrite($request->getPathInfo(), $oldStoreId);
         if ($oldRewrite) {
             $rewrite = $this->urlFinder->findOneByData([UrlRewrite::ENTITY_TYPE => $oldRewrite->getEntityType(), UrlRewrite::ENTITY_ID => $oldRewrite->getEntityId(), UrlRewrite::STORE_ID => $this->storeManager->getStore()->getId(), UrlRewrite::IS_AUTOGENERATED => 1]);
             if ($rewrite && $rewrite->getRequestPath() !== $oldRewrite->getRequestPath()) {
                 return $this->redirect($request, $rewrite->getRequestPath(), OptionProvider::TEMPORARY);
             }
         }
     }
     $rewrite = $this->getRewrite($request->getPathInfo(), $this->storeManager->getStore()->getId());
     if ($rewrite === null) {
         return null;
     }
     if ($rewrite->getRedirectType()) {
         return $this->processRedirect($request, $rewrite);
     }
     $request->setAlias(\Magento\Framework\UrlInterface::REWRITE_REQUEST_PATH_ALIAS, $rewrite->getRequestPath());
     $request->setPathInfo('/' . $rewrite->getTargetPath());
     return $this->actionFactory->create('Magento\\Framework\\App\\Action\\Forward', ['request' => $request]);
 }
Esempio n. 21
0
 /**
  * Validate and Match Cms Page and modify request
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return bool
  */
 public function match(\Magento\Framework\App\RequestInterface $request)
 {
     $identifier = trim($request->getPathInfo(), '/');
     $condition = new \Magento\Framework\Object(['identifier' => $identifier, 'continue' => true]);
     $this->_eventManager->dispatch('cms_controller_router_match_before', ['router' => $this, 'condition' => $condition]);
     $identifier = $condition->getIdentifier();
     if ($condition->getRedirectUrl()) {
         $this->_response->setRedirect($condition->getRedirectUrl());
         $request->setDispatched(true);
         return $this->actionFactory->create('Magento\\Framework\\App\\Action\\Redirect', ['request' => $request]);
     }
     if (!$condition->getContinue()) {
         return null;
     }
     /** @var \Magento\Cms\Model\Page $page */
     $page = $this->_pageFactory->create();
     $pageId = $page->checkIdentifier($identifier, $this->_storeManager->getStore()->getId());
     if (!$pageId) {
         return null;
     }
     $request->setModuleName('cms')->setControllerName('page')->setActionName('view')->setParam('page_id', $pageId);
     $request->setAlias(\Magento\Framework\Url::REWRITE_REQUEST_PATH_ALIAS, $identifier);
     return $this->actionFactory->create('Magento\\Framework\\App\\Action\\Forward', ['request' => $request]);
 }
Esempio n. 22
0
 /**
  * Validate and Match News Author and modify request
  * @param \Magento\Framework\App\RequestInterface $request
  * @return bool
  * //TODO: maybe remove this and use the url rewrite table.
  */
 public function match(RequestInterface $request)
 {
     if (!$this->dispatched) {
         $urlKey = trim($request->getPathInfo(), '/');
         $origUrlKey = $urlKey;
         /** @var Object $condition */
         $condition = new Object(['url_key' => $urlKey, 'continue' => true]);
         $this->eventManager->dispatch('sample_news_controller_router_match_before', ['router' => $this, 'condition' => $condition]);
         $urlKey = $condition->getUrlKey();
         if ($condition->getRedirectUrl()) {
             $this->response->setRedirect($condition->getRedirectUrl());
             $request->setDispatched(true);
             return $this->actionFactory->create('Magento\\Framework\\App\\Action\\Redirect', ['request' => $request]);
         }
         if (!$condition->getContinue()) {
             return null;
         }
         $entities = ['author' => ['prefix' => $this->scopeConfig->getValue('sample_news/author/url_prefix', ScopeInterface::SCOPE_STORES), 'suffix' => $this->scopeConfig->getValue('sample_news/author/url_suffix', ScopeInterface::SCOPE_STORES), 'list_key' => $this->scopeConfig->getValue('sample_news/author/list_url', ScopeInterface::SCOPE_STORES), 'list_action' => 'index', 'factory' => $this->authorFactory, 'controller' => 'author', 'action' => 'view', 'param' => 'id']];
         foreach ($entities as $entity => $settings) {
             if ($settings['list_key']) {
                 if ($urlKey == $settings['list_key']) {
                     $request->setModuleName('sample_news')->setControllerName($settings['controller'])->setActionName($settings['list_action']);
                     $request->setAlias(Url::REWRITE_REQUEST_PATH_ALIAS, $urlKey);
                     $this->dispatched = true;
                     return $this->actionFactory->create('Magento\\Framework\\App\\Action\\Forward', ['request' => $request]);
                 }
             }
             if ($settings['prefix']) {
                 $parts = explode('/', $urlKey);
                 if ($parts[0] != $settings['prefix'] || count($parts) != 2) {
                     continue;
                 }
                 $urlKey = $parts[1];
             }
             if ($settings['suffix']) {
                 $suffix = substr($urlKey, -strlen($settings['suffix']) - 1);
                 if ($suffix != '.' . $settings['suffix']) {
                     continue;
                 }
                 $urlKey = substr($urlKey, 0, -strlen($settings['suffix']) - 1);
             }
             /** @var \Sample\News\Model\Author $instance */
             $instance = $settings['factory']->create();
             $id = $instance->checkUrlKey($urlKey, $this->storeManager->getStore()->getId());
             if (!$id) {
                 return null;
             }
             $request->setModuleName('sample_news')->setControllerName('author')->setActionName('view')->setParam('id', $id);
             $request->setAlias(Url::REWRITE_REQUEST_PATH_ALIAS, $origUrlKey);
             $request->setDispatched(true);
             $this->dispatched = true;
             return $this->actionFactory->create('Magento\\Framework\\App\\Action\\Forward', ['request' => $request]);
         }
     }
     return null;
 }
Esempio n. 23
0
 /**
  * Dispatch SOAP request.
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function dispatch(\Magento\Framework\App\RequestInterface $request)
 {
     $path = $this->_pathProcessor->process($request->getPathInfo());
     $this->_request->setPathInfo($path);
     $this->areaList->getArea($this->_appState->getAreaCode())->load(\Magento\Framework\App\Area::PART_TRANSLATE);
     try {
         if ($this->_isWsdlRequest()) {
             $this->validateWsdlRequest();
             $responseBody = $this->_wsdlGenerator->generate($this->_request->getRequestedServices(), $this->_request->getScheme(), $this->_request->getHttpHost(), $this->_soapServer->generateUri());
             $this->_setResponseContentType(self::CONTENT_TYPE_WSDL_REQUEST);
             $this->_setResponseBody($responseBody);
         } else {
             if ($this->_isWsdlListRequest()) {
                 $servicesList = [];
                 foreach (array_keys($this->_wsdlGenerator->getListOfServices()) as $serviceName) {
                     $servicesList[$serviceName]['wsdl_endpoint'] = $this->_soapServer->getEndpointUri() . '?' . \Magento\Webapi\Model\Soap\Server::REQUEST_PARAM_WSDL . '&services=' . $serviceName;
                 }
                 $renderer = $this->rendererFactory->get();
                 $this->_setResponseContentType($renderer->getMimeType());
                 $this->_setResponseBody($renderer->render($servicesList));
             } else {
                 $this->_soapServer->handle();
             }
         }
     } catch (\Exception $e) {
         $this->_prepareErrorResponse($e);
     }
     return $this->_response;
 }
Esempio n. 24
0
 /**
  * Dispatch SOAP request.
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function dispatch(\Magento\Framework\App\RequestInterface $request)
 {
     $path = $this->_pathProcessor->process($request->getPathInfo());
     $this->_request->setPathInfo($path);
     $this->areaList->getArea($this->_appState->getAreaCode())->load(\Magento\Framework\App\Area::PART_TRANSLATE);
     try {
         if (!$this->_appState->isInstalled()) {
             throw new WebapiException(__('Magento is not yet installed'));
         }
         if ($this->_isWsdlRequest()) {
             $responseBody = $this->_wsdlGenerator->generate($this->_request->getRequestedServices(), $this->_soapServer->generateUri());
             $this->_setResponseContentType(self::CONTENT_TYPE_WSDL_REQUEST);
             $this->_setResponseBody($responseBody);
         } else {
             $consumerId = $this->_oauthService->validateAccessToken($this->_getAccessToken());
             $this->_request->setConsumerId($consumerId);
             $this->_soapServer->handle();
         }
     } catch (\Exception $e) {
         $this->_prepareErrorResponse($e);
     }
     return $this->_response;
 }
 /**
  * {@inheritdoc}
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return string
  */
 public function getCurrentSecureUrl(\Magento\Framework\App\RequestInterface $request)
 {
     return $this->url->getBaseUrl('link', true) . ltrim($request->getPathInfo(), '/');
 }
Esempio n. 26
0
 /**
  * Handle REST request
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function dispatch(\Magento\Framework\App\RequestInterface $request)
 {
     $path = $this->_pathProcessor->process($request->getPathInfo());
     $this->_request->setPathInfo($path);
     $this->areaList->getArea($this->_appState->getAreaCode())->load(\Magento\Framework\App\Area::PART_TRANSLATE);
     try {
         $this->checkPermissions();
         $route = $this->getCurrentRoute();
         if ($route->isSecure() && !$this->_request->isSecure()) {
             throw new \Magento\Webapi\Exception(__('Operation allowed only in HTTPS'));
         }
         /** @var array $inputData */
         $inputData = $this->_request->getRequestData();
         $serviceMethodName = $route->getServiceMethod();
         $serviceClassName = $route->getServiceClass();
         $inputData = $this->overrideParams($inputData, $route->getParameters());
         $inputParams = $this->_serializer->getInputData($serviceClassName, $serviceMethodName, $inputData);
         $service = $this->_objectManager->get($serviceClassName);
         /** @var \Magento\Framework\Service\Data\AbstractExtensibleObject $outputData */
         $outputData = call_user_func_array([$service, $serviceMethodName], $inputParams);
         $outputData = $this->dataObjectConverter->processServiceOutput($outputData);
         if ($this->_request->getParam(PartialResponseProcessor::FILTER_PARAMETER) && is_array($outputData)) {
             $outputData = $this->partialResponseProcessor->filter($outputData);
         }
         $this->_response->prepareResponse($outputData);
     } catch (\Exception $e) {
         $maskedException = $this->_errorProcessor->maskException($e);
         $this->_response->setException($maskedException);
     }
     return $this->_response;
 }
Esempio n. 27
0
 /**
  * {@inheritdoc}
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return string
  */
 public function getCurrentSecureUrl(\Magento\Framework\App\RequestInterface $request)
 {
     $alias = $request->getAlias(\Magento\Framework\Url::REWRITE_REQUEST_PATH_ALIAS) ?: $request->getPathInfo();
     return $this->storeManager->getStore()->getBaseUrl('link', true) . ltrim($alias, '/');
 }
Esempio n. 28
0
 /**
  * Handle REST request
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function dispatch(\Magento\Framework\App\RequestInterface $request)
 {
     $path = $this->_pathProcessor->process($request->getPathInfo());
     $this->_request->setPathInfo($path);
     $this->areaList->getArea($this->_appState->getAreaCode())->load(\Magento\Framework\App\Area::PART_TRANSLATE);
     try {
         if ($this->isSchemaRequest()) {
             $this->processSchemaRequest();
         } else {
             $this->processApiRequest();
         }
     } catch (\Exception $e) {
         $maskedException = $this->_errorProcessor->maskException($e);
         $this->_response->setException($maskedException);
     }
     return $this->_response;
 }
Esempio n. 29
0
 /**
  * Retrieve secure url for current request
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return string
  */
 protected function _getCurrentSecureUrl($request)
 {
     $alias = $request->getAlias(\Magento\Framework\Url::REWRITE_REQUEST_PATH_ALIAS) || $request->getPathInfo();
     return $this->_storeManager->getStore()->getBaseUrl('link', true) . ltrim($alias, '/');
 }
Esempio n. 30
0
 /**
  * Retrieve current secure url
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return string
  */
 protected function _getCurrentSecureUrl($request)
 {
     return $this->_url->getBaseUrl('link', true) . ltrim($request->getPathInfo(), '/');
 }