Carrega os arquivos de configuração e os armazena em variável local.

@param string $dir
966087
private function preloadFiles($dir)
    {
        $finder = new Finder();

        $files = $finder->in($dir)->files()->name('*.json');

        foreach ($files as $file) {
            $filenameParts = explode('.', $file->getFilename());

            if (count($filenameParts) >= 3) {
                $env = $filenameParts[count($filenameParts) - 2];
            } else {
                $env = false;
            }

            if ($env == false || $env == $this->app['env']) {
                $json = json_decode(file_get_contents($file->getRealpath()), true);

                $params = null;

                if (isset($json['_params'])) {
                    $params = $json['_params'];
                }

                $cfgIndex = count($this->files);

                $this->files[$cfgIndex] = array(
                    'file' => $file->getRealpath(),
                    '_params' => $params,
                    '_priority' => isset($json['_priority']) ? $json['_priority'] : 0,
                );
            }
        }

        usort($this->files, array($this, 'sortByPriority'));
    }
770128
public function mkdir($dir)
    {
        if (!is_dir($dir)) {
            if (false === @mkdir($dir, $this->mode, true)) {
                $error = error_get_last();
                if (!is_dir($dir)) {
                    if ($error) {
                        throw new IOException(
                            sprintf('Failed to create "%s": %s.', $dir, $error['message']),
                            0,
                            null,
                            $dir
                        );
                    }
                    throw new IOException(sprintf('Failed to create "%s"', $dir), 0, null, $dir);
                }
            }
        }
    }
720823
public function loadDir($dir)
    {
        $partialsFiles = scandir($dir);
        $partialsFiles = array_slice($partialsFiles, 2);

        foreach ($partialsFiles as $partialsFile) {

            $partialsFilePath = $dir . $partialsFile;

            if (is_file($partialsFilePath)) {
                $this->loadFile($partialsFilePath);
            } elseif (is_dir($partialsFilePath)) {
                $this->loadDir($partialsFilePath . DIRECTORY_SEPARATOR);
            }
        }
    }
1272235
public function setTemplateDir($dir)
    {
        $tmpDir = rtrim($dir, '/\\') . DIRECTORY_SEPARATOR;
        if (is_dir($tmpDir) === false) {
            throw new Exception('The template directory: "' . $tmpDir . '" does not exists, create the directory or specify an other location !');
        }
        $this->templateDir[] = $tmpDir;
    }
646580
private function rmdir($dir)
    {
        // remove all files
        $files = scandir($dir);
        foreach ($files as $file) {
            if ($file == '.' || $file == '..') {
                continue;
            }

            $path = $dir . '/' . $file;
            if (is_dir($path)) {
                $this->rmdir($path);
            } elseif (is_file($path)) {
                unlink($path);
            }
        }

        rmdir($dir);
    }
314007
public function setDir($dir)
    {
        $dir = rtrim($dir, '/');
        if (!is_dir($dir)) {
            mkdir($dir, 0700, true);
        }
        $this->dir = $dir;

        return $this;
    }
637765
public function setDir($dir)
    {
        if (!is_dir($dir)) {
            throw new FileNotFoundException(sprintf('Config "%s" is not a directory.', is_string($dir) ? $dir : (is_object($dir) ? get_class($dir) : gettype($dir))));
        }

        $newDir = realpath($dir).'/';
        if (null === $this->configDirectory) {
            $this->configDirectory = $newDir;

            return $this;
        }

        if ($newDir === $this->configDirectory) {
            return $this;
        }

        $this->configDirectory = $newDir;
        $this->flushAll();

        return $this;
    }
1033429
static public function install($dir = ".")
    {
        $cookieCode = md5(rand());
        $strReplaceS = array("{SRC_DIR}", "{CUR_DIR}", "{COOKIE_CODE}");
        $strReplaceR = array(__DIR__."/..", $dir, $cookieCode);
        $f = fopen($dir . "/.htaccess", "a");
        if(strpos(file_get_contents($dir."/.htaccess"), "##START twofactor-dir")===false)
        {
            fwrite($f, str_replace($strReplaceS, $strReplaceR, file_get_contents(__DIR__ . "/../files/x.htaccess")));
        }
        else
        {
            //I get the old cookie code
            $preg = "/RewriteCond %{HTTP_COOKIE}  !twofactorDir-.*=(.*)/";
            $ret = array();
            preg_match($preg, file_get_contents($dir."/.htaccess"),$ret);
            $strReplaceR[2] = $ret[1];
        }
        fclose($f);

        $f = fopen($dir . "/redirect.php", "w");
        fwrite($f, str_replace($strReplaceS,$strReplaceR,file_get_contents(__DIR__ . "/../files/redirect.php")));
        fclose($f);

        $f = fopen($dir . "/get_qr.php", "w");
        fwrite($f, str_replace($strReplaceS,$strReplaceR,file_get_contents(__DIR__ . "/../files/get_qr.php")));
        fclose($f);

        fclose(fopen($dir . "/secret.php", "a")); //create secret if it doesn't exists
    }
802889
public function dirDelete($dir)
    {
        $dir = $this->alias->resolve($dir);

        if (!is_dir($dir)) {
            return;
        }

        $this->_dirDelete($dir);
    }
477261
public function createDir($dir)
    {
        $oldMask = umask(0);
        @mkdir($dir, self::PERMISSION, true);
        umask($oldMask);
    }
1072165
private function __dir(string $dir) : bool
  {
    if (!is_dir($dir)) {
      mkdir($dir, 0777, true);
    }

    if (is_dir($dir)) return true;

    return false;
  }
889157
public function setCacheDir($dir)
    {
        $this->cacheDir = $dir;

        if (!is_dir($this->cacheDir)) {
            $this->createDir($this->cacheDir);
        }
    }
76260
public function addHelperDir($dir)
    {
        if (true === file_exists($dir) && true === is_dir($dir)) {
            $this->getApplication()->getAutoloader()->registerNamespace('BackBee\Renderer\Helper', $dir);
        }

        return $this;
    }
1340874
public static function setApplicationDir(array $dir)
    {
        if (DIRECTORY_SEPARATOR == '\\') {//windows
            array_walk($dir, function (&$val) {
                $val = str_replace('/', DIRECTORY_SEPARATOR, $val);
            });
        }
        self::$appDir = array_merge(self::$appDir, $dir);
    }
529864
public static function createDir($dir)
    {
        try {
            if (!is_dir($dir) && @mkdir($dir, 0775, true) === false) {
                throw new \Exception(t('Can\'t create directory ') . $dir);
            }
        } catch (\Exception $e) {
            Logger::log($e->getMessage(), LOG_WARNING);
            if (!file_exists(dirname($dir))) {
                throw new GeneratorException($e->getMessage() . $dir);
            }
        }
    }
675345
protected function makeDir($directory)
    {
        if (!$this->filesystem->isDirectory($directory)) {
            $this->filesystem->makeDirectory($directory, 0777, true);
        }
    }
1029017
protected function mkDir($dir)
    {
        if (!file_exists($dir)) {
            mkdir($dir, self::DIR_MODE, true);
            chmod($dir, self::DIR_MODE);
        }
        if (!is_dir($dir)) {
            throw new \Exception("Failed to create directory: $dir");
        }
    }