public function __construct(array $scanDirs, $cacheDir)
{
$this->setCacheDir($cacheDir);
// Make sure the cache directories exist.
$r = true;
if (!file_exists($cacheDir)) {
$r &= mkdir($cacheDir, 0755, true);
}
$types = [Addon::TYPE_ADDON, Addon::TYPE_LOCALE, Addon::TYPE_THEME];
$scanDirs += array_fill_keys($types, []);
foreach ($types as $type) {
if (!$this->typeUsesMultiCaching($type)) {
$dir = "{$cacheDir}/{$type}";
if (!file_exists($dir)) {
$r &= mkdir($dir, 0755);
}
}
$this->scanDirs[$type] = (array) $scanDirs[$type];
}
if (!$r) {
trigger_error('Could not create necessary addon cache directories.', E_USER_WARNING);
}
}