当前位置: 首页>>代码示例>>PHP>>正文


PHP RequestInterface::setModuleName方法代码示例

本文整理汇总了PHP中Magento\Framework\App\RequestInterface::setModuleName方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestInterface::setModuleName方法的具体用法?PHP RequestInterface::setModuleName怎么用?PHP RequestInterface::setModuleName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\App\RequestInterface的用法示例。


在下文中一共展示了RequestInterface::setModuleName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: match

 /**
  * 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]);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:41,代码来源:Router.php

示例2: match

 /**
  * 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;
 }
开发者ID:DRAJI,项目名称:Rapidmage,代码行数:40,代码来源:Router.php

示例3: process

 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;
 }
开发者ID:kietluu,项目名称:magento2-backend-training,代码行数:16,代码来源:CustomRouter.php

示例4: process

 /**
  * 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;
 }
开发者ID:kietluu,项目名称:magento2-backend-training,代码行数:22,代码来源:NoRouteHandler.php

示例5: process

 /**
  * @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;
 }
开发者ID:kietluu,项目名称:magento2-backend-training,代码行数:20,代码来源:NoRouteHandler.php

示例6: forward

 /**
  * @param string $action
  * @return $this
  */
 public function forward($action)
 {
     $this->request->initForward();
     if (!empty($this->params)) {
         $this->request->setParams($this->params);
     }
     if (!empty($this->controller)) {
         $this->request->setControllerName($this->controller);
         // Module should only be reset if controller has been specified
         if (!empty($this->module)) {
             $this->request->setModuleName($this->module);
         }
     }
     $this->request->setActionName($action);
     $this->request->setDispatched(false);
     return $this;
 }
开发者ID:IlyaGluschenko,项目名称:protection,代码行数:21,代码来源:Forward.php

示例7: process

 public function process(\Magento\Framework\App\RequestInterface $request)
 {
     $moduleName = 'cms';
     $controllerName = 'index';
     $actionName = 'index';
     $request->setModuleName($moduleName)->setControllerName($controllerName)->setActionName($actionName);
     return true;
 }
开发者ID:swnsma,项目名称:magento2,代码行数:8,代码来源:NoRouteHandler.php

示例8: process

 /**
  * 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;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:19,代码来源:NoRouteHandler.php

示例9: match

 /**
  * 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');
 }
开发者ID:PeterReuleke,项目名称:module-news,代码行数:20,代码来源:Router.php

示例10: match

 /**
  * 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');
 }
开发者ID:luxwan13,项目名称:magento2-learning,代码行数:20,代码来源:Router.php

示例11: process

 /**
  * Check and process no route request
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return bool
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function process(\Magento\Framework\App\RequestInterface $request)
 {
     $noRoutePath = $this->_config->getValue('web/default/no_route', 'default');
     if ($noRoutePath) {
         $noRoute = explode('/', $noRoutePath);
     } else {
         $noRoute = array();
     }
     $moduleName = isset($noRoute[0]) ? $noRoute[0] : 'core';
     $actionPath = isset($noRoute[1]) ? $noRoute[1] : 'index';
     $actionName = isset($noRoute[2]) ? $noRoute[2] : 'index';
     $request->setModuleName($moduleName)->setControllerName($actionPath)->setActionName($actionName);
     return true;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:21,代码来源:NoRouteHandler.php

示例12: match

 /**
  * 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]);
 }
开发者ID:pyvil,项目名称:magento2-blog-module,代码行数:21,代码来源:Router.php

示例13: match

 /**
  * {@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;
 }
开发者ID:mirasvit,项目名称:module-blog,代码行数:17,代码来源:Router.php

示例14: match

 /**
  * @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');
 }
开发者ID:V3N0m21,项目名称:test-example,代码行数:18,代码来源:Router.php

示例15: match

 /**
  * 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]);
 }
开发者ID:niransingh,项目名称:magento2,代码行数:52,代码来源:Router.php


注:本文中的Magento\Framework\App\RequestInterface::setModuleName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。