public function __construct($options)
{
if (!isset($options['source'])) {
throw new \RuntimeException('missing source directory');
}
if (!isset($options['target'])) {
throw new \RuntimeException('missing target directory');
}
$options += array('mode' => self::RECOMPILE_NORMAL, 'mkdir' => 0777, 'helpers' => array());
if (!isset($options['adapter'])) {
$options['adapter'] = new Adapter\FileAdapter($options['source']);
}
if (!($target = realpath($options['target'])) || !is_dir($target)) {
if ($options['mkdir'] === false) {
throw new \RuntimeException(sprintf('target directory %s not found', $options['target']));
}
if (!mkdir($options['target'], $options['mkdir'], true)) {
throw new \RuntimeException(sprintf('unable to create target directory %s', $options['target']));
}
}
$this->options = array('source' => $options['source'], 'target' => $target, 'mode' => $options['mode'], 'adapter' => $options['adapter'], 'helpers' => $options['helpers']);
$this->paths = array();
$this->cache = array();
}