/** * Return a default View instance. * * @return \View\View * @throw \BadMethodCallException */ protected function getView(array $data = array()) { list(, $caller) = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); $method = $caller['function']; // $path = str_replace('\\', '/', static::class); if (preg_match('#^App/Controllers/(.*)$#i', $path, $matches)) { $view = $matches[1] . '/' . ucfirst($method); return View::make($view, $data); } else { if (preg_match('#^App/Modules/(.+)/Controllers/(.*)$#i', $path, $matches)) { $view = $matches[2] . '/' . ucfirst($method); return View::make($view, $data, $matches[1]); } } throw new BadMethodCallException('Invalid Controller namespace: ' . static::class); }
/** * Return a new View Response from the application. * * @param string $view * @param array $data * @param int $status * @param array $headers * @return \Http\Response */ public static function view($view, $data = array(), $status = 200, array $headers = array()) { return static::make(View::make($view, $data), $status, $headers); }