當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。