public function resolvePath($template, $from = '')
{
$source = implode('/', $this->normalizePath($this->options['source']));
$parts = $this->normalizePath($source . '/' . dirname($from) . '/' . $template);
foreach ($this->normalizePath($source) as $i => $part) {
if ($part !== $parts[$i]) {
throw new \RuntimeException(sprintf('%s is outside the source directory', $template));
}
}
$path = trim(substr(implode('/', $parts), strlen($source)), '/');
return $path;
}