Exemple #1
0
 static function connect($_db = false)
 {
     if (!$_db) {
         $_db = Configure::get('db');
     }
     if (!self::$initialized) {
         self::getInstance();
     }
     if (!self::$isConnected) {
         if (\RedBean_Facade::setup(sprintf('mysql:host=%s;dbname=%s', $_db['host'], $_db['db']), $_db['user'], $_db['password'])) {
             return self::$isConnected = true;
         }
         return self::$isConnected = false;
     }
     return true;
 }
Exemple #2
0
 private function __setResponse()
 {
     $this->response['type'] = ($ext = $this->route->getParams('ext')) ? $ext : \Ctv\Utils\Configure::get('Default.ext');
 }
Exemple #3
0
 /**
  * Mapea la url para obtener el controlador, accion y argumentos
  * @return Object Route
  */
 private function mapUrl($pattern, $settings = array())
 {
     // 		 pattern /:controller/:action[/param1/param2/param3]
     // $pattern = "#^/(?<controller>[\w-]+)(?:/(?<action>[\w-]+))?(?:/(?<args>[^?]+).*?|$)?#";
     if (preg_match($pattern, $this->url, $appMatches)) {
         $this->params['controller'] = isset($appMatches['controller']) ? $appMatches['controller'] : \Ctv\Utils\Configure::get('Default.controller');
         //$appMatches['controller'];
         $this->params['action'] = isset($appMatches['action']) ? $appMatches['action'] : \Ctv\Utils\Configure::get('Default.action');
         if (!empty($this->params['named'])) {
             foreach ($this->params['named'] as $n => $captureParam) {
                 if (isset($appMatches[$captureParam])) {
                     $this->params['named'][$captureParam] = $appMatches[$captureParam];
                     unset($this->params['named'][$n]);
                 }
             }
         }
         if (isset($appMatches['args'])) {
             $this->params['args'] = explode('/', $appMatches['args']);
         }
         if (!empty($this->arguments)) {
             foreach ($this->arguments as $n => $key) {
                 if (isset($this->params['named'][$key])) {
                     $this->arguments[$n] = $this->params['named'][$key];
                     unset($this->params['named'][$key]);
                 } else {
                     unset($this->arguments[$n]);
                 }
             }
             $this->params['args'] = empty($this->params['args']) ? $this->arguments : array_merge($this->params['args'], $this->arguments);
         }
     } else {
         $this->params['controller'] = \Ctv\Utils\Configure::get('Default.controller');
         $this->params['action'] = \Ctv\Utils\Configure::get('Default.action');
     }
     // Overload Settings
     if (!empty($settings)) {
         $this->params = array_merge($this->params, $settings);
     }
     return $this;
 }