- throw new Error(sprintf('Unable to write to: %s', $output), $token->getLine(), $stream->getSourceContext(), $e);
+ throw new Error(sprintf('Unable to write "%s"', $this->output), $token->getLine(), $stream->getSourceContext(), $e);
+ }
+
+ //Without output file mtime
+ if (($mtime = filemtime($this->output)) === false) {
+ //Throw error
+ throw new Error(sprintf('Unable to get "%s" mtime', $this->output), $token->getLine(), $stream->getSourceContext(), $e);
+ }
+
+ //TODO: get mimetype for images ? and set _format ?
+
+ try {
+ //Generate asset url
+ $asset = $this->router->generate($this->route, [ 'file' => $file, 'u' => $mtime ]);
+ //Catch router exceptions
+ } catch (RouteNotFoundException|MissingMandatoryParametersException|InvalidParameterException $e) {
+ //Throw error
+ throw new Error(sprintf('Unable to generate asset route "%s"', $this->route), $token->getLine(), $stream->getSourceContext(), $e);