Vanilla\AddonManager::__construct PHP Method

__construct() public method

Initialize a new instance of the {@link AddonManager} class.
public __construct ( array $scanDirs, string $cacheDir )
$scanDirs array An array of root-relative directories to scan indexed by **Addon::TYPE_*** constant. Applications and plugins are treated as the same so pass their directories as an array with the **Addon::TYPE_ADDON** key.
$cacheDir string The path to the cache.
    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);
        }
    }