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; }
private function open() { if (!\Sauce\Path::check($this->filename, 'f', 'w')) { if (!($this->file = fopen($this->filename, 'a'))) { throw new \Exception('Log file is not writable (' . $this->filename . ').'); } } else { $this->file = fopen($this->filename, 'a'); } if (!is_resource($this->file)) { throw new \Exception('Log file resource is not valid anymore'); } }
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,