skeeks\cms\helpers\FileHelper::getFirstExistingFileArray PHP Method

getFirstExistingFileArray() public static method

Первый существующий файл
public static getFirstExistingFileArray ( string[] $files = [] ) : string | null
$files string[]
return string | null
    public static function getFirstExistingFileArray($files = [])
    {
        foreach ($files as $file) {
            if (file_exists(\Yii::getAlias($file))) {
                return $file;
            }
        }
        return null;
    }

Usage Example

Beispiel #1
0
 /**
  * Путь к файлу в этом расширении
  *
  * @param $filePath
  * @return null|string
  */
 public function getFilePath($filePath)
 {
     $composerFiles = [];
     foreach ($this->alias as $name => $path) {
         $composerFiles[] = $path . '/' . $filePath;
     }
     return FileHelper::getFirstExistingFileArray($composerFiles);
 }