Generates a configuration based on the given request and instantiate a compiler for the response. If $db is not not given the current instance if any will be used.
function(string $request, bbn\Db $db = NULL)
{
// Need to be in a bbn environment, this is the absolute path of the server's root directory
if (!defined('BBN_PUBLIC')) {
$this->error('You must define the constant $this->fpath as the root of your public document');
die('You must define the constant $this->fpath as the root of your public document');
}
/** @todo Remove? */
$this->_set_prefix();
if (!$db) {
$db = Db::getInstance();
}
if ($db) {
$this->db = $db;
}
$this->request = $request;
// Creation of a config object
$config = new Cdn\Config($request, $this->db);
// Checking request validity
if ($config->check()) {
// Getting a configuration array
$this->cfg = $config->get();
if (!empty($this->cfg['content']['js']) || $this->cfg['is_component']) {
$this->mode = 'js';
}
else {
if (!empty($this->cfg['content']['css'])) {
$this->mode = 'css';
}
}
if ($this->mode) {
$this->cp = new Cdn\Compiler($this->cfg);
}
}
}