/**
* Collects data for the given Request and Response.
*
* @param Request $request A Request instance
* @param Response $response A Response instance
* @param \Exception $exception An Exception instance
*
* @api
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
{
$messages = array();
$content = $response->getContent();
$path = '';
$fileContent = '';
$template = $request->attributes->get('_template');
if (is_null($template)) {
$templateName = $request->attributes->get('template');
list($front, $format, $engine) = explode('.', $templateName);
$templateParts = explode(":", $front);
$template = new TemplateReference($templateParts[0], $templateParts[1], $templateParts[2], $format, $engine);
}
if ($template instanceof TemplateReference) {
$locale = $request->attributes->get('_locale', $request->getLocale());
$catalogue = new MessageCatalogue($locale);
$path = $template->getPath();
/**
* Check if $path is a resource
*/
if (strstr($path, '@')) {
$kernel = $this->container->get('kernel');
$path = $kernel->locateResource($path);
$fileContent = file_get_contents($path);
}
$this->twigExtractor->extractTemplate($path, $catalogue);
$messages = $catalogue->all();
}
$this->data = array('content' => $content, 'file_content' => $fileContent, 'messages' => $messages, 'path' => $path);
}