Ejemplo n.º 1
0
 /**
  * Match path
  *
  * @param string $path
  * @return boolean
  */
 public function match($pathInfo = null)
 {
     $pathInfo = trim($pathInfo, '/');
     foreach ($this->rules as $regex => $rule) {
         if (!preg_match($regex, $pathInfo, $matches)) {
             continue;
         }
         if (isset($rule['maps']) && is_array($rule['maps'])) {
             $params = array();
             foreach ($rule['maps'] as $pos => $key) {
                 if (isset($matches[$pos]) && '' !== $matches[$pos]) {
                     $params[$key] = urldecode($matches[$pos]);
                 }
             }
             if (isset($rule['defaults'])) {
                 $params += $rule['defaults'];
             }
             Cola::setReg('_params', $params);
         }
         return $rule;
     }
     if ($this->enableDynamicMatch) {
         return $this->dynamicMatch($pathInfo);
     }
     return false;
 }
Ejemplo n.º 2
0
 /**
  * Init Cola_Ext_Cache
  *
  * @param mixed $name
  * @return Cola_Ext_Cache
  */
 public function cache($name = null)
 {
     is_null($name) && ($name = $this->_cache);
     if (is_array($name)) {
         return Cola::factory('Cola_Ext_Cache', $name);
     }
     $regName = "_cola_cache_{$name}";
     if (!($cache = Cola::getReg($regName))) {
         $config = (array) Cola::getConfig($name);
         $cache = Cola::factory('Cola_Ext_Cache', $config);
         Cola::setReg($regName, $cache);
     }
     return $cache;
 }