function response() { $ajax = Request::ajax(); $ajax === 'd' and Request::ajax(true); $naked = Input::get(Block::$nakedVar, $ajax); $onlyBlocks = Input::get('_blocks'); if (!isset($onlyBlocks) and $ajax) { $onlyBlocks = ''; } $singleBlock = (isset($onlyBlocks) and !is_array($onlyBlocks)); $firstServed = in_array(head((array) $onlyBlocks), array('!', '1', '')); if ($singleBlock and !$naked) { // preventing DoubleEdge from wrapping response into $fullView. Input::merge(array(Block::$nakedVar => 1)); } $rendering = new Rendering($this, $onlyBlocks); $rendering->slugs = $this->slugs; $response = null; if ($singleBlock and $firstServed or $this->breaksout()) { isset($this->served) or Log::info_Layout('No specific server on this route.'); $rendering->result = array($this->servedResponse()); $ajax and $response = $rendering->result[0]; } elseif ($singleBlock) { $rendering->render($this); $rendering->result = array_slice($rendering->result, 1, -1, true); foreach ($rendering->result as $block) { foreach (arrize($block) as $blockResponse) { is_object($blockResponse) and $blockResponse->isServed = true; } } } else { $rendering->render($this); } Request::ajax(null); if ($response) { // do nothing. } elseif ($onlyBlocks and !$rendering->result) { $paths = join(', ', (array) $onlyBlocks); Log::warn_Layout("No blocks to render have matched given path(s): {$paths}."); $response = $this->servedResponse(E_INPUT); } else { $naked and $rendering->unwrap(); $response = $rendering->served ?: Response::adapt(''); $content = $rendering->join($ajax); if (!$naked and !$singleBlock and is_scalar($content) and $full = $this->view()) { $content = $full->with(compact('content')); } if (method_exists($response, 'set')) { $response->set($content); } else { $response->content = $content; } } // restoring value that could have been set in the beginning. Input::merge(array(Block::$nakedVar => $naked)); return Response::postprocess($response); }