Пример #1
0
 /**
  * Homepage -- default method
  */
 public function index()
 {
     Debug::timer('test');
     Assets::add('main', Assets::TYPE_CSS);
     Assets::add('default', Assets::TYPE_JS);
     /*
      * Sample information about access to database data
      * Default read:
      */
     //        $modelSample = new mSample();
     //        $rows = $modelSample->get();
     //        Debug::var_dump($rows);
     //        $modelSample->get(2);
     /*
      * Sample get instance of component
      */
     $componentEmail = new cEmail($this->config, $this->router);
     Debug::var_dump('test');
     Debug::var_dump([432, 654]);
     Debug::timer('test');
     $this->set('variable', 'how to set variable to view');
     $this->set('links', array('produkt' => $this->router->getUrl('products', 'detail', 123, array('list' => 5))));
 }
Пример #2
0
 /**
  * Load controller
  * 
  * @param array $cmv array('controller' => '', 'method' => '', 'vars' => array())
  */
 private function loadController($cmv)
 {
     //if we have nothing to do, then quit
     if (empty($cmv) or empty($cmv['controller']) or empty($cmv['method'])) {
         trigger_error('Not call controller->method', E_USER_ERROR);
         exit;
     }
     if (!is_array($cmv['controller'])) {
         $cmv['controller'] = array($cmv['controller']);
     }
     self::$controller = implode("\\", $cmv['controller']);
     self::$method = $cmv['method'];
     $this->view->setView(self::$controller . DS . self::$method);
     //add controllers folder to begin and uppercase first letter class name
     array_unshift($cmv['controller'], 'controllers');
     end($cmv['controller']);
     $cmv['controller'][key($cmv['controller'])] = ucfirst($cmv['controller'][key($cmv['controller'])]);
     $cmv['controller'] = "\\" . implode("\\", $cmv['controller']);
     $controller = new $cmv['controller']($this->config, $this->router, $this->view);
     if (method_exists($controller, 'beforeMethod')) {
         Debug::timer('beforeMethod');
         $controller->beforeMethod();
         Debug::timer('beforeMethod');
     }
     if (is_callable(array($controller, $cmv['method']), true)) {
         Debug::timer('Controller logic');
         call_user_func_array(array($controller, $cmv['method']), $cmv['vars']);
         Debug::timer('Controller logic');
     }
     if (method_exists($controller, 'afterMethod')) {
         Debug::timer('afterMethod');
         $controller->afterMethod();
         Debug::timer('afterMethod');
     }
 }