/** * Searches for a schedule base on name and description * * @return Template * @author Dan Cox */ public function search() { $search = Input::get('term'); $schedules = DB::search('Schedule', function ($builder) use($search) { $builder->where('u.name LIKE :search'); $builder->orWhere('u.description LIKE :search'); $builder->setParameter('search', '%' . $search . '%'); }); return Template::make('pages/results', ['schedules' => $schedules, 'search' => $search]); }
<?php /** * Routes - all standard Routes are defined here. * * @author David Carr - dave@daveismyname.com * @version 3.0 */ /** Define static routes. */ // Default Routing Route::any('', function () { /* $view = View::make('Default') ->shares('title', __('Welcome')) ->withContent(__('Yep! It works.')); $template = Template::make('default')->withContent($view); */ $template = Template::make('default')->shares('title', __('Welcome'))->nest('content', 'Default', array('content' => __('Yep! It works.'))); return Response::make($template); }); // The Framework's Language Changer. Route::any('language/{locale}', array('before' => 'referer', 'uses' => 'App\\Controllers\\Language@change')); /** End default Routes */
/** * Returns a specific page from the documentation * * @return void * @author Dan Cox */ public function docPage($page) { return Template::make('docs/' . $page); }
//-------------------------------------------------------------------------- // Application Missing Route Handler //-------------------------------------------------------------------------- use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; App::missing(function (NotFoundHttpException $exception) { $status = $exception->getStatusCode(); $headers = $exception->getHeaders(); if (Request::ajax()) { // An AJAX request; we'll create a JSON Response. $content = array('status' => $status); // Setup propely the Content Type. $headers['Content-Type'] = 'application/json'; return Response::json($content, $status, $headers); } // We'll create the templated Error Page Response. $response = Template::make('default')->shares('title', 'Error ' . $status)->nest('content', 'Error/' . $status); // Setup propely the Content Type. $headers['Content-Type'] = 'text/html'; return Response::make($response->render(), $status, $headers); }); //-------------------------------------------------------------------------- // Try To Register Again The Config Manager //-------------------------------------------------------------------------- use Config\Repository as ConfigRepository; use Support\Facades\Facade; if (CONFIG_STORE == 'database') { // Get the Database Connection instance. $connection = $app['db']->connection(); // Get a fresh Config Loader instance. $loader = $app->getConfigLoader(); // Setup Database Connection instance.
/** * Test Template::forge() given invalid driver * * @test * @expectedException \FuelException */ public function test_forge_expected_exception_given_invalid_driver() { Template::make('helloworld'); }
/** * View all activities for schedule * * @return Template * @author Dan Cox */ public function activities($id) { $schedule = DB::find('Schedule', $id); $activities = $schedule->activities()->slice(0); return Template::make('pages/activities', ['schedule' => $schedule, 'activities' => $activities]); }
/** * Create from the given result a Response instance and send it. * * @param mixed $response * * @return \Symfony\Component\HttpFoundation\Response */ protected function processResponse($response) { if ($response instanceof Renderable) { // If the response which is returned from the called Action is a Renderable instance, // we will assume we want to render it using the Controller's templated environment. if (is_string($this->layout) && !$response instanceof Layout) { $response = Template::make($this->layout, $this->template)->with('content', $response); } // Create a proper Response instance. $response = new Response($response->render(), 200, array('Content-Type' => 'text/html')); } // If the response is not a instance of Symfony Response, create a proper one. if (!$response instanceof SymfonyResponse) { $response = new Response($response); } return $response; }