public function __construct(Config $cfg, AbstractModule $mod)
 {
     parent::__construct($cfg, $mod);
     $this->config = $cfg;
     $this->module = $mod;
     $this->dbConn = $mod->dbConn;
     $this->queryBuilder = $mod->queryBuilder;
     $this->request = $this->module->request;
     $this->contentType = 'application/json';
 }
Esempio n. 2
0
 public function __construct(Config $cfg, AbstractModule $module, $uri)
 {
     parent::__construct($cfg, $module);
     $this->config = $cfg;
     $this->handlerForMethods = ['get' => 'get', 'post' => 'create', 'put' => 'update', 'delete' => 'delete'];
     $this->router->addFilters([':num' => function ($val) {
         return is_numeric($val) ? true : false;
     }]);
     $req = Request::getCurrent();
     $handler = $this->handlerForMethods[strtolower($req->method)];
     // Filters for the Restful functionality
     $this->router->appendRoutes(['/:num/:resource' => array($this, '__routeToRelatedHandler'), '/:num' => array($this, $handler . 'One'), '/:str' => array($this, '__routeToVerbHandler'), '/' => array($this, $handler)]);
     $response = $this->router->check($uri);
     if ($response instanceof Response) {
         $this->response = $response;
     } else {
         $this->response = new Response(empty($response) ? [] : $response, $this->config->get('defaultContentType'));
     }
 }
Esempio n. 3
0
 public function __construct(Config $cfg, AbstractModule $module = null, $params = null)
 {
     parent::__construct($cfg, $module);
     $this->view = new Smarty();
     $cfg->addKnownOptions('default', ['viewsDir' => 'views']);
     $cfg->refreshCache();
     $viewBaseDir = $module->getPath($cfg->get('directory'), $cfg->get('viewsDir')) . DIRECTORY_SEPARATOR;
     $cfg->addKnownOptions('smarty', ['pluginsDir' => $viewBaseDir . 'plugins', 'templateDir' => $viewBaseDir . 'templates', 'cacheDir' => $viewBaseDir . 'cache', 'compileDir' => $viewBaseDir . 'compiles']);
     $cfg->refreshCache('smarty');
     // Load the entire smarty optionSet
     $smartyCfg = $cfg->getSet('smarty');
     // Set the directories for smarty files.
     $this->view->setPluginsDir($module->getPath($viewBaseDir, $smartyCfg['pluginsDir']));
     $this->view->setTemplateDir($module->getPath($viewBaseDir, $smartyCfg['templateDir']));
     $this->view->setCacheDir($module->getPath($viewBaseDir, $smartyCfg['cacheDir']));
     $this->view->setCompileDir($module->getPath($viewBaseDir, $smartyCfg['compileDir']));
     //
     $this->assign = [];
 }
Esempio n. 4
0
 public function __construct(Config $config, AbstractModule $module)
 {
     parent::__construct($config, $module);
     $this->config->set('contentType', 'application/json');
 }