Ejemplo n.º 1
0
 public function __construct($compile_dir = NULL, $template_dir = NULL, $cache_dir = NULL, $plugins_dir = [], $config_dir = [], $disable_security = FALSE, Loops $loops = NULL)
 {
     parent::__construct($loops);
     $loops = $this->getLoops();
     $application = $loops->getService("application");
     $renderer = $loops->getService("renderer");
     $app_dir = $application->app_dir;
     $cache_dir = $application->cache_dir;
     //adjust directories
     $compile_dir = Misc::fullPath($compile_dir ?: "renderer_cache/smarty", $cache_dir);
     $template_dir = array_map(function ($path) use($app_dir) {
         return Misc::fullPath($path, $app_dir);
     }, (array) ($template_dir ?: $renderer->view_dir));
     $cache_dir = Misc::fullPath($compile_dir ?: "renderer_cache/smarty_cache", $cache_dir);
     $plugins_dir = array_map(function ($path) use($app_dir) {
         return Misc::fullPath($path, $app_dir);
     }, (array) $plugins_dir);
     $config_dir = array_map(function ($path) use($app_dir) {
         return Misc::fullPath($path, $app_dir);
     }, (array) $config_dir);
     //setup smarty
     $this->smarty = new Smarty();
     $this->smarty->setCompileDir($compile_dir);
     $this->smarty->setTemplateDir($template_dir);
     $this->smarty->setCacheDir($cache_dir);
     $this->smarty->addPluginsDir($plugins_dir);
     $this->smarty->setConfigDir($config_dir);
     if ($disable_security) {
         $this->smarty->disableSecurity();
     }
     //register extra modifier
     $this->smarty->registerPlugin("modifier", "render", [$loops->getService("renderer"), "render"]);
     $this->smarty->registerPlugin("modifier", "tr", [$this, "tr"]);
 }
Ejemplo n.º 2
0
 public function __construct($database, Loops $loops = NULL)
 {
     parent::__construct($loops);
     // Get config from Loops redis service
     $config = Redis::getConfig($this->getLoops());
     // Set Backend information
     \Resque::setBackend("{$config->host}:{$config->port}", (int) $database);
 }
Ejemplo n.º 3
0
 public function __construct($view_dir = [], Loops $loops = NULL)
 {
     parent::__construct($loops);
     $this->view_dir = array_map(function ($dir) {
         return Misc::fullPath($dir, $this->getLoops()->getService("application")->app_dir);
     }, (array) $view_dir);
     $this->view_dir = array_filter($this->view_dir, "is_dir");
     $loops_views = realpath(__DIR__ . "/../../../views");
     if (!in_array($loops_views, $this->view_dir)) {
         $this->view_dir[] = $loops_views;
     }
 }
Ejemplo n.º 4
0
 public static function getService(ArrayObject $config, Loops $loops)
 {
     $redis = parent::getService($config, $loops);
     $params = static::getDefaultConfig($loops);
     $params->merge($config);
     $params = $params->toArray();
     //use closure to forward connect call - Redis objects can not be analyzed for some reason by the reflection api
     $connect = function ($host = "localhost", $port = 6379, $timeout = 0, $persistent_id = NULL, $retry_interval = NULL, $persistent = FALSE) use($redis) {
         if ($persistent) {
             return $redis->pconnect($host, $port, $timeout, $persistent_id, $retry_interval);
         } else {
             return $redis->connect($host, $port, $timeout, $persistent_id, $retry_interval);
         }
     };
     Misc::reflectionFunction($connect, $params);
     if (!empty($params["password"])) {
         $redis->auth($params["password"]);
     }
     if (!empty($params["database"])) {
         $redis->select((int) $params["database"]);
     }
     return $redis;
 }
Ejemplo n.º 5
0
 protected static function getDefaultConfig(Loops $loops = NULL)
 {
     $config = parent::getDefaultConfig($loops);
     $config->plugin = static::getDefaultPlugin($loops);
     return $config;
 }
Ejemplo n.º 6
0
 public function __construct($base_url = "/", $error_page = "Loops\\ErrorPage", Loops $loops = NULL)
 {
     parent::__construct($loops);
     $this->base_url = $base_url;
     $this->error_page = $error_page;
 }
Ejemplo n.º 7
0
 public function offsetGet($key)
 {
     if (parent::offsetExists($key)) {
         return parent::offsetGet($key);
     }
     return $this->repository(Misc::camelize($key));
 }
Ejemplo n.º 8
0
 public function __construct(Loops $loops = NULL)
 {
     parent::__construct($loops);
     // Initialize resque config
     $this->getLoops()->getService("resque");
 }
Ejemplo n.º 9
0
 /**
  * If a log level name is given TRUE or FALSE is returned based on if
  * logging of this level is enabled.
  *
  * If no valid log level is given, __get of the parent class is returned.
  *
  * @param string $key A LogLevel name.
  * @return mixed TRUE or FALSE if logging of the given log level is available
  */
 public function __get($key)
 {
     if (self::isValidLogLevel($key)) {
         return $this->isLogging($key);
     }
     return parent::__get($key);
 }