public function __construct($level = self::INFO, $driver = self::FILESYSTEM, $output_file = null) { $this->levels = A($this->levels); if (is_an_array($level)) { $options = $level; $level = $options->level; $driver = $options->driver; $output_file = $options->file; } if (defined('self::' . strtoupper($driver))) { $this->driver = constant('self::' . strtoupper($driver)); } else { $this->driver = self::STDERR; } if (defined('self::' . strtoupper($level))) { $this->level = constant('self::' . strtoupper($level)); } else { $this->level = self::INFO; } if ($this->driver == self::FILESYSTEM) { if ($output_file === null) { $this->filename = \Sauce\Path::join(APP_ROOT, 'logs', 'application.log'); } else { $this->filename = $output_file; } $this->open(); } }
public function render($route, $log = null) { $views_path = \Sauce\Path::join(APP_ROOT, 'vendor/brainsware/bacon/Views'); $not_found_view_path = 'NotFound/index.tpl'; $loader = new \Bacon\Loader($views_path, $not_found_view_path, false); $twig = new \Twig_Environment($loader); echo $twig->render($not_found_view_path, $this->context->getArrayCopy()); }
public function traverse($directory, $namespaces = []) { if (!is_an_array($directory)) { $path = \Sauce\Path::info($directory); $path->absolute = $directory; $path->dirname = basename(dirname($path->absolute)); $path->is_dir = is_dir($path->absolute); $directory = $path; } $namespaces = V($namespaces); $namespaces->push($directory->filename); $entries = \Sauce\Path::ls($directory->absolute); // Add extensive path info to the listing $entries = $entries->map(function ($entry) use($directory) { $path = \Sauce\Path::info($entry); $path->absolute = \Sauce\Path::join($directory->absolute, $entry); $path->dirname = basename(dirname($path->absolute)); $path->is_dir = is_dir($path->absolute); return $path; }); $entries = $entries->map(function ($entry) use($namespaces) { if ($entry->is_dir) { return $entry; } $entry->class_name = "\\" . $namespaces->join("\\") . "\\" . $entry->filename; $entry->is_class = class_exists($entry->class_name); return $entry; }); foreach ($entries->to_array() as $entry) { if ($entry->is_dir) { // Recurse! $entries->push($this->traverse($entry, $namespaces)); continue; } } return $entries; }
public function index() { if (!file_exists(\Sauce\Path::join(APP_ROOT, 'Views/NotFound/index.tpl'))) { return new \Bacon\Presenter\NotFoundHtml(null, Ar($this->params)); } }
/* PHP's builtin webserver doesn't know FallbackResource. So we have to do it on our * own in this case. * * Check whether given URI maps to a file or is to be handled by us. */ if (is_cli_server()) { $path = $params->request_uri; if (empty($path) || $path === null) { $path = $env->request_uri; } /* Remove any GET parameters (<uri>?foo=bar) if present. */ $question_mark = strpos($path, '?'); if ($question_mark !== false) { $path = substr($path, 0, $question_mark); } if (is_file(\Sauce\Path::join(HTDOCS, $path))) { return false; } } /* PHP forms the $_FILES array in the following way: * $_FILES => { * name => [ file1, file2, file3, ... ], * size => [ .... ], * ... * * So we just transform it to: * * $files (\Sauce\Vector) => [ * { * name => file1, * size => 1234,