Bolt\Controller\Backend\FileManager::getRelatedFiles PHP Method

getRelatedFiles() private method

Matches: foo(_local)?\.*(.dist)? i.e., if we're editing config.yml, we also want to check for config.yml.dist and config_local.yml
private getRelatedFiles ( Bolt\Filesystem\Handler\FileInterface $file ) : Bolt\Filesystem\Handler\FileInterface[]
$file Bolt\Filesystem\Handler\FileInterface
return Bolt\Filesystem\Handler\FileInterface[]
    private function getRelatedFiles(FileInterface $file)
    {
        // Match foo(_local).*(.dist)
        $base = $file->getFilename();
        if (Str::endsWith($base, '.dist')) {
            $base = substr($base, 0, -5);
        }
        $ext = pathinfo($base, PATHINFO_EXTENSION);
        $base = Str::replaceLast(".{$ext}", '', $base);
        $base = Str::replaceLast('_local', '', $base);
        $dir = $file->getParent();
        $related = [];
        foreach ([".{$ext}", "_local.{$ext}", ".{$ext}.dist"] as $tail) {
            $f = $dir->getFile($base . $tail);
            if ($f->getFilename() !== $file->getFilename() && $f->exists()) {
                $related[] = $f;
            }
        }
        return $related;
    }