public function __construct($classname, $interface, $default, Loops $loops = NULL) { parent::__construct($loops); $this->classname = $classname; $this->interface = $interface; $this->default = $default; }
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"]); }
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); }
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; } }
/** * @param string $level Only log messages with this level or higher. * @param int $log_php_errors Set to a PHP error constant to enable loggin of php generated errors. * @param bool $with_line Set if the file and line should be displayed on PHP errors. * @param bool $with_trace Set if the context/trace infomation should be displayed on PHP errors. * @param Loops The loops object */ public function __construct($level = LogLevel::WARNING, $log_php_errors = NULL, $with_line = FALSE, $with_trace = FALSE, Loops $loops = NULL) { if ($log_php_errors === NULL) { $log_php_errors = error_reporting(); } parent::__construct($loops); $this->setLogLevel($level); if (!self::$php_error_handler_set) { set_error_handler([__CLASS__, "php_error_handler"], E_ALL); self::$php_error_handler_set = TRUE; } self::$error_handling_instances[] = [$this, $log_php_errors, $with_line, $with_trace]; }
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; }
public function __construct($driver = NULL, $dbname = NULL, $host = NULL, $port = NULL, $user = NULL, $password = NULL, $path = NULL, $devmode = TRUE, Loops $loops = NULL) { parent::__construct($loops); $loops = $this->getLoops(); $application = $loops->hasService('application') ? $loops->getService('application') : NULL; //check if mysql is linked via docker - configure default options if yes if (getenv('MYSQL_PORT') && preg_match('/^(.*?):\\/\\/(.*?):(.*?)$/', getenv('MYSQL_PORT'), $match)) { if ($driver === NULL) { $driver = 'pdo_mysql'; } if ($host === NULL) { $host = $match[2]; } if ($port === NULL) { $port = $match[3]; } if ($user === NULL) { $user = getenv('MYSQL_ENV_MYSQL_USER') ?: 'root'; } if ($password === NULL) { $password = getenv('MYSQL_ENV_MYSQL_PASSWORD') ?: getenv('MYSQL_ENV_MYSQL_ROOT_PASSWORD'); } if ($dbname === NULL) { $dbname = getenv('LOOPS_DATABASE') ?: (getenv('MYSQL_ENV_MYSQL_DATABASE') ?: 'loops'); } } //check if postgres is linked via docker - configure default options if yes if (getenv('POSTGRES_PORT') && preg_match('/^(.*?):\\/\\/(.*?):(.*?)$/', getenv('POSTGRES_PORT'), $match)) { if ($driver === NULL) { $driver = 'pdo_pgsql'; } if ($host === NULL) { $host = $match[2]; } if ($port === NULL) { $port = $match[3]; } if ($user === NULL) { $user = getenv('POSTGRES_ENV_POSTGRES_USER') ?: 'postgres'; } if ($password === NULL) { $password = getenv('POSTGRES_ENV_POSTGRES_PASSWORD'); } if ($dbname === NULL) { $dbname = getenv('LOOPS_DATABASE') ?: 'loops'; } } //default options - sqlite with database in cache directory if ($driver === NULL) { $driver = "pdo_sqlite"; } if ($host === NULL) { $host = "localhost"; } if ($dbname === NULL) { $dbname = "loops"; } if ($path === NULL) { $path = $application ? "{$application->cache_dir}/{$dbname}.sqlite" : "{$dbname}.sqlite"; } //set vars as read-only for reference $this->driver = $driver; $this->host = $host; $this->port = $port; $this->user = $user; $this->password = $password; $this->dbname = $dbname; $this->path = $path; $this->devmode = $devmode; //setup doctrine entity maneger $databaseConfig = ["driver" => $driver, "host" => $host, "user" => $user, "password" => $password, "dbname" => $dbname, "path" => $path]; $doctrineConfig = Setup::createAnnotationMetadataConfiguration(["{$application->app_dir}/inc/"], $devmode, "{$application->cache_dir}/doctrine_proxies", $loops->hasService("cache") ? $loops->getService("cache") : NULL, $loops->getService("doctrine_annotation_reader") instanceof SimpleAnnotationReader); //autoloading of proxy classes - needed when unserializing doctrine entities //(doctrine should take care about this but is doesn't) spl_autoload_register(function ($classname) use($application) { //filename according to doctrine logic $file = str_replace("\\", "", substr($classname, strlen("DoctrineProxies\\"))) . '.php'; if (file_exists("{$application->cache_dir}/doctrine_proxies/{$file}")) { include "{$application->cache_dir}/doctrine_proxies/{$file}"; } }); $this->entity_manager = EntityManager::create($databaseConfig, $doctrineConfig); }
public function __construct(Loops $loops = NULL) { parent::__construct($loops); // Initialize resque config $this->getLoops()->getService("resque"); }