Esempio n. 1
0
 /**
  * Registers services related to the module
  *
  * @param DiInterface $di Dependency Injection Container
  */
 public function registerServices(DiInterface $di)
 {
     /**
      * Read configuration
      */
     $config = (require __DIR__ . "/config/config.php");
     /**
      * Setting up the view component
      */
     $di->setShared('view', function () {
         $view = new View();
         $view->setViewsDir(__DIR__ . '/views/');
         $view->setTemplateBefore('main');
         $view->registerEngines([".volt" => function ($view, $di) {
             $volt = new Volt($view, $di);
             $volt->setOptions(['compiledPath' => function ($templatePath) {
                 return realpath(__DIR__ . "/../../var/volt") . '/' . md5($templatePath) . '.php';
             }, 'compiledExtension' => '.php', 'compiledSeparator' => '%']);
             return $volt;
         }]);
         return $view;
     });
     /**
      * Database connection is created based in the parameters defined in the configuration file
      */
     $di->setShared('db', function () use($config) {
         return new Connection(['host' => $config->database->host, 'username' => $config->database->username, 'password' => $config->database->password, 'dbname' => $config->database->dbname]);
     });
 }
Esempio n. 2
0
 protected function _getViewDisabled($level = null)
 {
     $view = new Phalcon\Mvc\View();
     $view->setViewsDir('unit-tests/views/');
     $view->setTemplateAfter('after');
     $view->setTemplateBefore('before');
     if ($level !== null) {
         $view->disableLevel($level);
     }
     $view->start();
     $view->render('test13', 'index');
     $view->finish();
     return $view;
 }
Esempio n. 3
0
 protected function _getViewDisabled($level = null)
 {
     $view = new View();
     $view->setViewsDir(PATH_DATA . "views" . DIRECTORY_SEPARATOR);
     $view->setTemplateAfter("after");
     $view->setTemplateBefore("before");
     if ($level !== null) {
         $view->disableLevel($level);
     }
     $view->start();
     $view->render("test13", "index");
     $view->finish();
     return $view;
 }