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


PHP JInput::def方法代码示例

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


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

示例1: testDef

 /**
  * Test the JInput::def method.
  *
  * @return  void
  *
  * @since   12.1
  */
 public function testDef()
 {
     $_REQUEST['foo'] = 'bar';
     $this->class->def('foo', 'nope');
     $this->assertThat($_REQUEST['foo'], $this->equalTo('bar'), 'Line: ' . __LINE__ . '.');
     $this->class->def('Joomla', 'is great');
     $this->assertThat($_REQUEST['Joomla'], $this->equalTo('is great'), 'Line: ' . __LINE__ . '.');
 }
开发者ID:joomla-projects,项目名称:media-manager-improvement,代码行数:15,代码来源:JInputTest.php

示例2: parseRoute

 /**
  * Parse the given route and return the name of a controller mapped to the given route.
  *
  * @param   string  $route  The route string for which to find and execute a controller.
  *
  * @return  string  The controller name for the given route excluding prefix.
  *
  * @since   1.0
  * @throws  \InvalidArgumentException
  */
 protected function parseRoute($route)
 {
     $controller = false;
     // Trim the query string off.
     $route = preg_replace('/([^?]*).*/u', '\\1', $route);
     // Sanitize and explode the route.
     $route = trim(static::parseUrl($route, PHP_URL_PATH), ' /');
     // If the route is empty then simply return the default route.  No parsing necessary.
     if ($route == '') {
         return $this->default;
     }
     // Iterate through all of the known route maps looking for a match.
     foreach ($this->maps as $key => $rule) {
         if (preg_match($rule['regex'], $route, $matches)) {
             // If we have gotten this far then we have a positive match.
             $controller = $rule['controller'];
             // Time to set the input variables.
             // We are only going to set them if they don't already exist to avoid overwriting things.
             foreach ($rule['vars'] as $i => $var) {
                 $this->input->def($var, $matches[$i + 1]);
                 // Don't forget to do an explicit set on the GET superglobal.
                 $this->input->get->def($var, $matches[$i + 1]);
             }
             $this->input->def('_rawRoute', $route);
             $name = $key;
             break;
         }
     }
     // We were unable to find a route match for the request.  Panic.
     if (!$controller) {
         throw new \InvalidArgumentException(sprintf('Unable to handle request for route `%s`.', $route), 404);
     }
     if (is_callable($this->parseHandler[$name])) {
         call_user_func_array($this->parseHandler[$name], array($controller, $this->input));
     }
     return $controller;
 }
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:47,代码来源:LegacyRouter.php


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