Loads the config files from the base directory.

@param string $basedir The base directory

@throws \BackBee\Config\Exception\InvalidBaseDirException Occurs if the base directory can't be read
486091
private function loadFromBaseDir($basedir, $overwrite = false)
    {
        foreach ($this->getYmlFiles($basedir) as $filename) {
            $this->loadFromFile($filename, $overwrite);
        }
    }
814553
public function getImages($dir, $basedir)
    {
        $files = array();
        $dir = $basedir . $dir;
        if ($handler = opendir($dir)) {
            while ($file = readdir($handler)) {
                $path = realpath("{$dir}/{$file}");
                if (is_file($path)) {
                    if (preg_match('/^[a-zA-z0-9=&,]+\.(gif|png|jpg|jpeg)$/', $file)) {
                        array_push($files, array(str_replace(array($basedir, '\\'), array('', '/'), $path),filesize($path)));
                    }
                }
            }
            closedir($handler);
        }
        
        return $files;
    }
602381
public function setSystemConfigDir($configDir)
    {
        if (!is_dir($configDir)) {
            throw new \InvalidArgumentException(
                sprintf('Invalid System Configuration Directory: %s', $configDir)
            );
        }

        $this->systemConfigDirectory = $configDir;

        return($this);
    }
801972
public static function globAll(string $baseDir, array $patterns, int $flags = 0): array
    {
        $files = [];
        $inverse = [];

        foreach ($patterns as $pattern) {
            if (strpos($pattern, '!') === 0) {
                $pattern = substr($pattern, 1);

                $inverse[] = static::glob(
                    rtrim($baseDir, '\\/') . '/' . ltrim($pattern, '\\/'),
                    $flags
                );
            } else {
                $files[] = static::glob(
                    rtrim($baseDir, '\\/') . '/' . ltrim($pattern, '\\/'),
                    $flags
                );
            }
        }

        if ($files !== []) {
            $files = array_unique(array_merge(...$files));
        }

        if ($inverse !== []) {
            $inverse = array_unique(array_merge(...$inverse));
        }

        return array_diff($files, $inverse);
    }
1003258
public function getBaseDir()
    {
        if (empty($this->baseDir)) {
            $this->baseDir = trim(str_replace('index.php', '', Server::get('SCRIPT_NAME')), '/');
        }

        return $this->baseDir;
    }
533423
protected function setUp($baseFileDir = null)
	{

		$locator = new FileLocator($baseFileDir);

		$resolver = new LoaderResolver(
			array(
				new PhpArrayFileLoader($locator),
				new JsonFileLoader($locator),
				new YamlFileLoader($locator)
			)
		);

		$this->fileLoader = new DelegatingLoader($resolver);

	}
863700
public function setConfigDir($configDir)
    {
        if (!is_dir($configDir)) {
            throw new \InvalidArgumentException(
                sprintf('Invalid Application Configuration Directory: %s', $configDir)
            );
        }

        $this->configDir = $configDir;

        return($this);
    }
497206
protected function initBaseDir($basePath)
    {
        if ($basePath) {
            $this->setBaseDir($basePath);
        } elseif (defined('BASE_PATH')) {
            $this->setBaseDir(BASE_PATH);
        } else {
            throw new BadMethodCallException("No BASE_PATH defined");
        }
    }
803449
public function recursivelyDeleteFromDirectory($baseDirectory)
    {
        if (!is_dir($baseDirectory)) {
            return;
        }

        $iterator = new \RecursiveDirectoryIterator($baseDirectory);
        $files = new \RecursiveIteratorIterator(
            $iterator,
            \RecursiveIteratorIterator::CHILD_FIRST
        );

        foreach ($files as $file) {
            $fname = $file->getFilename();
            if ($fname == '.' || $fname == '..') {
                continue;
            }

            if ($file->isDir()) {
                $this->recursivelyDeleteFromDirectory($file->getRealPath());
            } else {
                unlink($file->getRealPath());
            }
        }

        rmdir($baseDirectory);

        return;
    }
375322
public function load($filenames='common', $basePath=null, $locale=null)
	{
	    $locale = $locale ?: $this->locale;
	    
	    $filenames = (array) $filenames;
	    
	    if (!$basePath) {
	        $basePath = Config::getCommonPath();
	    } elseif (!file_exists($basePath)) {
	        $basePath = Config::getRootPath() . trim($basePath, '/');
	    }
	    
	    foreach ($filenames as $file) {
	        if (!is_file($file)) {
	            $file = rtrim($basePath, '/') . '/lang/' . $locale . '/'. $file . '.lang.php';
	        }
	        
	        $content = Ioc::load($file);
	        
	        if ($content && is_array($content)) {
	            $this->data = array_merge($this->data, $content);
	        }
	    }
	}
1057144
protected function makeDirectory($path, $baseDir = null)
	{
		if (is_dir($path) === true) {
			return;
		}

		if ($this->chmod === null) {
			$chmod = 0777;
		} else {
			$chmod = $this->chmod;
		}
		mkdir($path, $chmod, true);

		// enforce the correct mode for all directories created
		if (strpos(PHP_OS, 'WIN') !== 0 && $baseDir !== null) {
			$path = strtr(str_replace($baseDir, '', $path), '\\', '/');
			$folders = explode('/', trim($path, '/'));
			foreach ($folders as $folder) {
				$baseDir .= $folder . DIRECTORY_SEPARATOR;
				chmod($baseDir, $chmod);
			}
		}
	}
600372
public function init(): void
    {
        parent::init();

        if ($this->name === null || !\is_string($this->name) || $this->name === '') {
            throw new InvalidConfigException('Formatter name must be defined');
        }
        if ($this->path === null) {
            throw new InvalidConfigException('File path property must be defined and be not empty');
        }
        foreach ($this->formatAdapterArray as $i => $formatAdapter) {
            $this->formatAdapterArray[$i] = Container::createObject($formatAdapter);

            if (!($this->formatAdapterArray[$i] instanceof IFormatAdapter)) {
                throw new InvalidConfigException(sprintf('Format adapter must be instance of %s.', IFormatAdapter::class));
            }
        }
    }
160710
protected function loadConfiguration($configFile = false)
    {
        if ($configFile === false) {
            return;
        }
        echo "\nLoad configuration";

        $configuration = require $configFile;

        foreach ($configuration as $name => $value) {
            if ($this->module->canSetProperty($name) == true) {
                $this->module->$name = $value;
            } else {
                throw new InvalidConfigException("Invalid configuration. Unknown configuration option '{$name}'");
            }
        }
        $this->module->loadComponents();
    }
564337
protected function getBaseDir()
    {
        if (!isset($this->config['mp3']['baseDir'])) {
            throw new \Exception(
                $this->translate->translate(
                    'baseDir is not currently set',
                    'mp3'
                )
            );
        }

        return $this->config['mp3']['baseDir'];
    }
1168751
public function addStaticPartial($baseDir, $name)
    {
        $file = $this->createPartialPath($baseDir, $name);

        if (!is_file($file)) {
            throw new LogicException(sprintf('Invalid base directory or file name provided "%s"', $file));
        }

        $this->staticPartials[$name] = $file;
        return $this;
    }
1306878
public function loadConfig($configFiles)
    {
        if (!is_array($configFiles)) {
            $configFiles = array($configFiles);
        }

        $this->configFiles = $configFiles;

        foreach ($configFiles as $configFile) {
            $this->config = array_merge(
                $this->config,
                $this->loadConfigFile($configFile)
            );
        }
    }
1239651
protected function getFiles(PhingFile $baseDir, DirectoryScanner $ds)
    {
        return $this->restrict($ds->getIncludedFiles(), $baseDir);
    }