Get all translations in given path for the given file extension (mustache | php).
@param  string $path     The path.
@param  string $fileType The file extension|type.
@return array        Translations.
494388
public function getTranslationsFromPath($path, $fileType)
    {
        // remove vendor/locomotivemtl/charcoal-app
        $base  = $this->appConfig->get('base_path');
        $glob  = $this->globRecursive($base.$path.'*.'.$fileType);
        $regex = $this->regEx($fileType);

        $translations = [];

        // Array index for the preg_match.
        $index = 'text';
        // if ($fileType == 'php') {
        //     $index = 'text';
        // }

        $k = 0;

        $this->climate()->inline('.');
        // Loop files to get original text.
        foreach ($glob as $k => $file) {
            $k++;
            $this->climate()->inline('.');
            $text = file_get_contents($file);

            if (preg_match($regex, $text)) {
                preg_match_all($regex, $text, $array);

                $i = 0;
                $t = count($array[$index]);
                $locales = $this->locales();

                for (; $i < $t; $i++) {
                    $this->climate()->inline('.');
                    $orig = $array[$index][$i];
                    foreach ($locales as $lang) {
                        $this->climate()->inline('.');
                        $this->translator()->setLocale($lang);
                        // By calling translate, we make sure all existings translations are taking into consideration.

                        $translations[$lang][$orig] = stripslashes($this->translator()->translate($orig));
                    }
                }
            }
        }
        $this->climate()->out('.');
        $this->climate()->green()->out('Translations parsed from '.$path);
        return $translations;
    }
1247236
public function getMigrationFiles($path)
    {
        $files = Helpers::rGlob($path.'/*_*.php');

        if ($files === false) {
            return [];
        }

        $files = array_map(function ($file) {
            return str_replace('.php', '', basename($file));

        }, $files);

        sort($files);

        return $files;
    }
1212470
public function getFilesWithExtension($path, $ext = 'php')
    {
        if (is_dir($path)) {
            return new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD // Ignore "Permission denied"
            ), '/^.+\.'.$ext.'$/i', RecursiveRegexIterator::GET_MATCH);
        } else {
            return [];
        }
    }
297033
public function getModelFiles($path)
    {
        $fileCollection = new FileCollection();

        $namespacePath = str_replace('\\', '/', $path . $this->getNamespace() . '/');

        $targetPath = $namespacePath;

        foreach ($this->getEntities() as $entity) {
            if ($entity->getRenderizable()) {
                if ($this->getLanguage() === 'php') {
                    if ($entity->getNamespace() !== '') {
                        $targetPath = $path . str_replace('\\', '/', $entity->getNamespace()) . '/';
                    }
                } elseif ($this->getLanguage() === 'java') {
                    if ($entity->getModule() !== '') {
                        $targetPath = $path . '/' . $this->getAutocodeConfiguration('package') . '/' . str_replace('.', '/', $entity->getModule()) . '/';
                    }
                }

                foreach ($this->getAutocodeEntityTemplates() as $template) {
                    $fileCollection->add($this->renderEntityTemplate($template, $entity, $targetPath));
                }
            }
        }

        if ($this->getLanguage() === 'php') {
            foreach ($this->modules as $module) {
                $targetPath = $path . str_replace('\\', '/', $this->moduleNamespaces[$module]) . '/';

                foreach ($this->getAutocodeModuleTemplates() as $template) {
                    $fileCollection->add($this->renderModuleTemplate($this, $template, $module, $targetPath));
                }
            }
        }

        return $fileCollection;
    }
666032
public function importTranslations($path, $type)
    {
        $separator = app('config')->get('antares/translations::export.separator');
        $content   = explode(PHP_EOL, file_get_contents($path));
        $list      = [];
        foreach ($content as $index => $line) {
            if ($index == 0) {
                continue;
            }
            array_push($list, explode($separator, $line));
        }


        $locale   = $list[0][1];
        $language = Languages::where('code', $locale)->first();
        try {
            DB::transaction(function() use($language, $list, $type) {
                $area   = request()->segment(6);
                DB::table('tbl_translations')->where('lang_id', $language->id)->where('area', $area)->delete();
                $insert = [];
                foreach ($list as $item) {
                    if (!isset($item[2]) or ! isset($item[3])) {
                        continue;
                    }
                    try {
                        $value = iconv('WINDOWS-1250', 'UTF-8', $item[3]);
                    } catch (Exception $ex) {
                        $value = $item[3];
                    }

                    $insert[] = [
                        'locale'  => $language->code,
                        'area'    => $area,
                        'group'   => 'antares/' . $item[0],
                        'lang_id' => $language->id,
                        'key'     => trim($item[2], '"'),
                        'value'   => trim($value, '"'),
                    ];
                }
                DB::table('tbl_translations')->insert($insert);
            });
            return true;
        } catch (Exception $e) {
            Log::warning($e);
            return false;
        }
    }
945211
protected function scanDirectory($path, $extensions)
    {
        if (is_file($path)) {
            $file = new \SplFileInfo($path);
            return array($this->getFileKey($file->getPath(), $file) => $file);
        }
        
        $files = array();
        $extensions = (array) $extensions;
        $iterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator(
                $path, 
                \FileSystemIterator::SKIP_DOTS 
                    | \FileSystemIterator::CURRENT_AS_FILEINFO)    
        );
        foreach ($iterator as $file) {
            if (in_array($file->getExtension(), $extensions)) {
                $files[$this->getFileKey($path, $file)] = $file;
            }
        }
        return $files;
    }
1286836
public static function getFileExt($path, $type = self::MIME_FINFO)
    {
        $mime = self::getFileMime($path, $type);
        return $mime ? self::mimeToExt($mime) : null;
    }
235012
private function getFileExtension($path) {
		if (empty($path)) return '';
		$ext = pathinfo($path, PATHINFO_EXTENSION);
		return strtolower($ext); 
	}
412398
public function extfile($path){
        $rtn["fullfilename"] = substr(strrchr($path, "/"), 1);
        $rtn["ext"] = substr(strrchr($path, "."), 1);
        $rtn["filename"] = substr($rtn["fullfilename"], 0, -(strlen($rtn["ext"])+1));
        return $rtn;
     }
1213135
public static function getInstanceByLocal($path)
    {
        $fileContent = file_get_contents($path);
        return new static([
            'isUploadedFile' => false,
            'name' => basename($path),
            'tempName' => $path,
            'type' => FileHelper::getMimeType($path),
            'size' => strlen($fileContent),
            'error' => UPLOAD_ERR_OK,
        ]);
    }
1102189
private function getFullPath($type, $path)
    {
        return sprintf('%s/%s/%s', $this->config['web_root_dir'], $this->config[$type . '_path'], $path);
    }
328391
public function getMimeTypeByExtension($path){

        if(!$this->mimeCache){
            $this->mimeCache = require \App::getAlias('disco.mime');
        }//if

        if(isset($this->mimeCache[$this->getExtension($path)])){
            return $this->mimeCache[$this->getExtension($path)];
        }//if

        return null;

    }
383945
private function get_files_from_folders( $path ) {

		$items = $this::get_folder_contents( $path );

		foreach ( $items as $type => &$location ) {
			$location = $this::get_folder_contents( trailingslashit( $location ) );
			sort( $location );
		}

		return $items;
	}
969040
public function getByFileExtension($fileExtension)
    {
        $fileExtension = ltrim($fileExtension);
        $result = [];
        foreach ($this->converters as $converter) {
            if (strcasecmp($fileExtension, $converter->getFileExtension()) === 0) {
                $result[] = $converter;
            }
        }

        return $result;
    }
206615
public static function get($path)
    {
        $ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
        if (!isset(self::$fileTypes[$ext])) {
            return false;
        }
        return self::$fileTypes[$ext];
    }
1185469
public function retrieveAvailableLocales($path = '/../Resources/translations/')
    {
        $locales = array();
        $data = $this->configHandler->getParameter('locales');

        foreach ($data as $locale) {
            $locales[$locale] = $locale;
        }

        return $locales;
    }
412893
public function get_extension($path){
        $type = $this->get_mime($path);
        $match = [];
        $ext = '';
        if( $type ){
            foreach( wp_get_mime_types() as $extensions => $content_type ){
                if( $content_type == $type ){
                    $ext = explode('|', $extensions)[0];
                    break;
                }
            }
        }
        return $ext;
    }