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


PHP RouteMatch::getParams方法代码示例

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


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

示例1: switchInstance

 /**
  * {@inheritDoc}
  */
 public function switchInstance(InstanceInterface $instance)
 {
     $container = $this->getContainer();
     $container->offsetSet('instance', $instance->getId());
     $url = $this->router->assemble($this->routeMatch->getParams(), ['name' => $this->routeMatch->getMatchedRouteName()]);
     $this->redirect($url);
 }
开发者ID:andreas-serlo,项目名称:athene2,代码行数:10,代码来源:CookieStrategy.php

示例2: switchInstance

 /**
  * {@inheritDoc}
  */
 public function switchInstance(InstanceInterface $instance)
 {
     if (!array_key_exists('HTTP_HOST', (array) $_SERVER)) {
         throw new Exception\RuntimeException(sprintf('Host not set.'));
     }
     $url = $this->router->assemble($this->routeMatch->getParams(), ['name' => $this->routeMatch->getMatchedRouteName()]);
     $hostNames = explode('.', $_SERVER['HTTP_HOST']);
     $tld = $hostNames[count($hostNames) - 2] . "." . $hostNames[count($hostNames) - 1];
     $url = 'http://' . $instance->getSubdomain() . '.' . $tld . $url;
     $this->redirect($url);
 }
开发者ID:andreas-serlo,项目名称:athene2,代码行数:14,代码来源:DomainStrategy.php

示例3: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $callback = function (MvcEvent $event) {
         $view = $event->getApplication()->getServiceManager()->get('ViewRenderer');
         $config = $event->getApplication()->getConfig();
         $controller = $event->getTarget();
         $rm = $event->getRouteMatch();
         if (!$rm instanceof RouteMatch) {
             $rm = new RouteMatch(array('module' => 'Application', '__NAMESPACE__' => 'Application\\Controller', '__CONTROLLER__' => 'index', 'controller' => 'Application\\Controller\\Index', 'action' => 'index'));
         }
         $params = $rm->getParams();
         $modulo = "";
         if (isset($params['__NAMESPACE__'])) {
             $paramsArray = explode("\\", $params['__NAMESPACE__']);
             $modulo = $paramsArray[0];
         }
         $controller = isset($params['__CONTROLLER__']) ? $params['__CONTROLLER__'] : "";
         $action = isset($params['action']) ? $params['action'] : null;
         $app = $event->getParam('application');
         $sm = $app->getServiceManager();
         $paramsConfig = ['modulo' => strtolower($modulo), 'controller' => strtolower($controller), 'action' => strtolower($action), 'baseHost' => $view->base_path("/"), 'cssStaticHost' => "", 'jsStaticHost' => "", 'statHost' => "", 'eHost' => "", 'statVers' => '?', 'min' => '', 'AppCore' => [], 'AppSandbox' => [], 'AppSchema' => ['modules' => [], 'requires' => []]];
         $view->inlineScript()->appendScript("var yOSON=" . json_encode($paramsConfig, JSON_FORCE_OBJECT));
     };
     $e->getApplication()->getEventManager()->getSharedManager()->attach('Zend\\Mvc\\Controller\\AbstractActionController', MvcEvent::EVENT_DISPATCH, $callback, 100);
     $e->getApplication()->getEventManager()->getSharedManager()->attach('Zend\\Mvc\\Application', MvcEvent::EVENT_DISPATCH_ERROR, $callback, 100);
 }
开发者ID:jrodev,项目名称:Yoson,代码行数:26,代码来源:Module.php

示例4: isActive

 /**
  * Returns whether page should be considered active or not
  *
  * This method will compare the page properties against the route matches
  * composed in the object.
  *
  * @param  bool $recursive  [optional] whether page should be considered
  *                          active if any child pages are active. Default is
  *                          false.
  * @return bool             whether page should be considered active or not
  */
 public function isActive($recursive = false)
 {
     if (!$this->active) {
         $reqParams = array();
         if ($this->routeMatch instanceof RouteMatch) {
             $reqParams = $this->routeMatch->getParams();
             if ($this->routeMatch->getMatchedRouteName() === $this->getRoute()) {
                 $this->active = true;
                 return true;
             }
         }
         $myParams = $this->params;
         if (null !== $this->controller) {
             $myParams['controller'] = $this->controller;
         } else {
             /**
              * @todo In ZF1, this was configurable and pulled from the front controller
              */
             $myParams['controller'] = 'index';
         }
         if (null !== $this->action) {
             $myParams['action'] = $this->action;
         } else {
             /**
              * @todo In ZF1, this was configurable and pulled from the front controller
              */
             $myParams['action'] = 'action';
         }
         if (count(array_intersect_assoc($reqParams, $myParams)) == count($myParams)) {
             $this->active = true;
             return true;
         }
     }
     return parent::isActive($recursive);
 }
开发者ID:ranxin1022,项目名称:zf2,代码行数:46,代码来源:Mvc.php

示例5: isExcluded

 /**
  * {@inheritDoc}
  */
 public function isExcluded()
 {
     $matchedRouteName = $this->routeMatch->getMatchedRouteName();
     $matchedRouteParams = $this->routeMatch->getParams();
     $matchedRoutePath = $this->getRoutePath($matchedRouteParams);
     foreach ($this->routes as $route) {
         if (is_string($route) && $route == $matchedRouteName) {
             return true;
         } elseif (is_array($route)) {
             if (isset($route['action']) && $this->getRoutePath($route) == $matchedRoutePath) {
                 return true;
             } elseif (!isset($route['action']) && $route['controller'] == $matchedRouteParams['controller']) {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:juliangut,项目名称:zf-maintenance,代码行数:21,代码来源:RouteExclusion.php

示例6: fromRoute

 public static function fromRoute(\Zend\Mvc\Router\RouteMatch $route)
 {
     $internalRoute = new self();
     $internalRoute->setRoute($route->getMatchedRouteName());
     $internalRoute->setParams($route->getParams());
     if ($_GET) {
         $internalRoute->setOptions(array('query' => $_GET));
     }
     return $internalRoute;
 }
开发者ID:stavarengo,项目名称:sta-commons,代码行数:10,代码来源:InternalRoute.php

示例7: __invoke

 /**
  * Generates a url given the name of a route.
  *
  * @see Zend\Mvc\Router\RouteInterface::assemble()
  * @see Zend\Router\RouteInterface::assemble()
  * @param  string $name Name of the route
  * @param  array $params Parameters for the link
  * @param  array|Traversable $options Options for the route
  * @param  bool $reuseMatchedParams Whether to reuse matched parameters
  * @return string Url For the link href attribute
  * @throws Exception\RuntimeException If no RouteStackInterface was
  *     provided
  * @throws Exception\RuntimeException If no RouteMatch was provided
  * @throws Exception\RuntimeException If RouteMatch didn't contain a
  *     matched route name
  * @throws Exception\InvalidArgumentException If the params object was not
  *     an array or Traversable object.
  */
 public function __invoke($name = null, $params = [], $options = [], $reuseMatchedParams = false)
 {
     if (null === $this->router) {
         throw new Exception\RuntimeException('No RouteStackInterface instance provided');
     }
     if (3 == func_num_args() && is_bool($options)) {
         $reuseMatchedParams = $options;
         $options = [];
     }
     if ($name === null) {
         if ($this->routeMatch === null) {
             throw new Exception\RuntimeException('No RouteMatch instance provided');
         }
         $name = $this->routeMatch->getMatchedRouteName();
         if ($name === null) {
             throw new Exception\RuntimeException('RouteMatch does not contain a matched route name');
         }
     }
     if (!is_array($params)) {
         if (!$params instanceof Traversable) {
             throw new Exception\InvalidArgumentException('Params is expected to be an array or a Traversable object');
         }
         $params = iterator_to_array($params);
     }
     if ($reuseMatchedParams && $this->routeMatch !== null) {
         $routeMatchParams = $this->routeMatch->getParams();
         if (isset($routeMatchParams[ModuleRouteListener::ORIGINAL_CONTROLLER])) {
             $routeMatchParams['controller'] = $routeMatchParams[ModuleRouteListener::ORIGINAL_CONTROLLER];
             unset($routeMatchParams[ModuleRouteListener::ORIGINAL_CONTROLLER]);
         }
         if (isset($routeMatchParams[ModuleRouteListener::MODULE_NAMESPACE])) {
             unset($routeMatchParams[ModuleRouteListener::MODULE_NAMESPACE]);
         }
         $params = array_merge($routeMatchParams, $params);
     }
     $options['name'] = $name;
     return $this->router->assemble($params, $options);
 }
开发者ID:froschdesign,项目名称:zend-view,代码行数:56,代码来源:Url.php

示例8: isActive

 /**
  * Returns whether page should be considered active or not
  *
  * This method will compare the page properties against the route matches
  * composed in the object.
  *
  * @param  bool $recursive  [optional] whether page should be considered
  *                          active if any child pages are active. Default is
  *                          false.
  * @return bool             whether page should be considered active or not
  */
 public function isActive($recursive = false)
 {
     if (!$this->active) {
         $reqParams = array();
         if ($this->routeMatch instanceof RouteMatch) {
             $reqParams = $this->routeMatch->getParams();
             if (isset($reqParams[ModuleRouteListener::ORIGINAL_CONTROLLER])) {
                 $reqParams['controller'] = $reqParams[ModuleRouteListener::ORIGINAL_CONTROLLER];
             }
             $pageParams = $this->params;
             if (null !== $this->controller) {
                 $pageParams['controller'] = $this->controller;
             }
             if (null !== $this->action) {
                 $pageParams['action'] = $this->action;
             }
             if (null !== $this->getRoute()) {
                 if ($this->routeMatch->getMatchedRouteName() === $this->getRoute() && count(array_intersect_assoc($reqParams, $pageParams)) == count($pageParams)) {
                     $this->active = true;
                     return $this->active;
                 } else {
                     return parent::isActive($recursive);
                 }
             }
         }
         $pageParams = $this->params;
         if (null !== $this->controller) {
             $pageParams['controller'] = $this->controller;
         } else {
             /**
              * @todo In ZF1, this was configurable and pulled from the front controller
              */
             $pageParams['controller'] = 'index';
         }
         if (null !== $this->action) {
             $pageParams['action'] = $this->action;
         } else {
             /**
              * @todo In ZF1, this was configurable and pulled from the front controller
              */
             $pageParams['action'] = 'index';
         }
         if (count(array_intersect_assoc($reqParams, $pageParams)) == count($pageParams)) {
             $this->active = true;
             return true;
         }
     }
     return parent::isActive($recursive);
 }
开发者ID:KBO-Techo-Dev,项目名称:MagazinePro-zf25,代码行数:60,代码来源:Mvc.php

示例9: staticGetParam

 /**
  * Mimics zf1 Request::getParam behavior
  *
  * Route match -> GET -> POST
  */
 public static function staticGetParam(RouteMatch $routeMatch, Request $request, $param = null, $default = null)
 {
     if ($param === null) {
         $params = (array) $routeMatch->getParams();
         if ($request instanceof ConsoleRequest) {
             return $params + (array) $request->getParams();
         }
         return $params + $request->getQuery()->toArray() + $request->getPost()->toArray();
     }
     if ($request instanceof ConsoleRequest) {
         $default = $request->getParam($param, $default);
     } else {
         $default = $request->getQuery($param, $request->getPost($param, $default));
     }
     return $routeMatch->getParam($param, $default);
 }
开发者ID:grizzm0,项目名称:zf2-for-1,代码行数:21,代码来源:LegacyParams.php

示例10: getNamesMVC

 /**
  * @param MVCEvent $e MVC event Object
  * @return Array nombre de module, controller y action con datos adicionales.
  */
 private function getNamesMVC(MvcEvent $e)
 {
     $rm = $e->getRouteMatch();
     if (!$rm instanceof RouteMatch) {
         $rm = new RouteMatch(array('module' => 'Application', '__NAMESPACE__' => 'Application\\Controller', '__CONTROLLER__' => 'index', 'controller' => 'Application\\Controller\\Index', 'action' => 'index'));
     }
     $params = $rm->getParams();
     $modulo = isset($params['__NAMESPACE__']) ? $params['__NAMESPACE__'] : "";
     $controller = isset($params['__CONTROLLER__']) ? $params['__CONTROLLER__'] : "";
     if (isset($params['controller'])) {
         $paramsArray = explode("\\", $params['controller']);
         $modulo = $paramsArray[0];
         $controller = $paramsArray[2];
     }
     $action = isset($params['action']) ? $params['action'] : null;
     return array('modulo' => strtolower($modulo), 'controller' => strtolower($controller), 'action' => strtolower($action), 'min' => '', 'AppCore' => [], 'AppSandbox' => [], 'AppSchema' => ['modules' => [], 'requires' => []]);
 }
开发者ID:jrodev,项目名称:ZF2sample,代码行数:21,代码来源:StoreScript.php

示例11: marshalSuccessResultFromRouteMatch

 /**
  * Create a successful RouteResult from the given RouteMatch.
  *
  * @param RouteMatch $match
  * @return RouteResult
  */
 private function marshalSuccessResultFromRouteMatch(RouteMatch $match)
 {
     $params = $match->getParams();
     if (array_key_exists(self::METHOD_NOT_ALLOWED_ROUTE, $params)) {
         return RouteResult::fromRouteFailure($this->allowedMethodsByPath[$params[self::METHOD_NOT_ALLOWED_ROUTE]]);
     }
     return RouteResult::fromRouteMatch($this->getMatchedRouteName($match->getMatchedRouteName()), $params['middleware'], $params);
 }
开发者ID:flipecristian,项目名称:apiZend,代码行数:14,代码来源:Zf2.php

示例12: prepareParams

 private function prepareParams(RouteMatch $routeMatch, $lang)
 {
     $params = $routeMatch->getParams();
     $params['lang'] = $lang;
     // We want to avoid this situation ie. : "/en/auth/login/index"
     // Otherwise we get: "/en/auth/login", nice and clear
     if ($params['action'] === 'index') {
         $params['action'] = null;
     }
     // We need to set this, because otherwise we achieve this:
     // "/en/auth/Module\\Auth\\Controller\\LoginController"
     $params['controller'] = $params['__CONTROLLER__'];
     return $params;
 }
开发者ID:omusico,项目名称:zf2-demo,代码行数:14,代码来源:LangRedirector.php

示例13: hasAccessDqlConfig

 /**
  * true if the routeMatch passed has the ACCESS_DQL_PARAM_NAME key
  * as a parameter and the value of the key is an array with elements
  * or a string that is not empty
  *
  * @param RouteMatch $routeMatch
  *
  * @return boolean
  */
 private function hasAccessDqlConfig(RouteMatch $routeMatch)
 {
     if (array_key_exists(self::ACCESS_DQL_PARAM_NAME, $routeMatch->getParams())) {
         $paramValue = $routeMatch->getParam(self::ACCESS_DQL_PARAM_NAME);
         switch (true) {
             case is_array($paramValue):
                 if (count($paramValue) == 0) {
                     return false;
                 } else {
                     return true;
                 }
             case is_string($paramValue):
                 if (empty($paramValue)) {
                     return false;
                 } else {
                     return true;
                 }
             default:
                 return false;
         }
     } else {
         return false;
     }
 }
开发者ID:decmade,项目名称:zendAbacAcl,代码行数:33,代码来源:UserAttributeEvaluatorListener.php

示例14: merge

 /**
  * Merge parameters from another match.
  * 
  * @param  RouteMatch $match
  * @return void
  */
 public function merge(self $match)
 {
     $this->params = array_merge($this->params, $match->getParams());
 }
开发者ID:noose,项目名称:zf2,代码行数:10,代码来源:RouteMatch.php

示例15: testSetParam

 public function testSetParam()
 {
     $match = new RouteMatch(array());
     $match->setParam('foo', 'bar');
     $this->assertEquals(array('foo' => 'bar'), $match->getParams());
 }
开发者ID:rajanlamic,项目名称:IntTest,代码行数:6,代码来源:RouteMatchTest.php


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