N98\Util\Console\Helper\MagentoHelper::checkMagerunFile PHP Method

checkMagerunFile() protected method

Check for magerun stop-file
protected checkMagerunFile ( array $folders ) : array
$folders array
return array
    protected function checkMagerunFile(array $folders)
    {
        foreach (array_reverse($folders) as $searchFolder) {
            if (!is_readable($searchFolder)) {
                if (OutputInterface::VERBOSITY_DEBUG <= $this->output->getVerbosity()) {
                    $this->output->writeln(sprintf('<debug>Folder <info>%s</info> is not readable. Skip.</debug>', $searchFolder));
                }
                continue;
            }
            $stopFile = '.' . pathinfo($this->_customConfigFilename, PATHINFO_FILENAME);
            $finder = Finder::create();
            $finder->files()->ignoreUnreadableDirs(true)->depth(0)->followLinks()->ignoreDotFiles(false)->name($stopFile)->in($searchFolder);
            $count = $finder->count();
            if ($count > 0) {
                $this->_magerunStopFileFound = true;
                $this->_magerunStopFileFolder = $searchFolder;
                $magerunFilePath = $searchFolder . DIRECTORY_SEPARATOR . $stopFile;
                $magerunFileContent = trim(file_get_contents($magerunFilePath));
                if (OutputInterface::VERBOSITY_DEBUG <= $this->output->getVerbosity()) {
                    $message = sprintf('<debug>Found stopfile \'%s\' file with content <info>%s</info></debug>', $stopFile, $magerunFileContent);
                    $this->output->writeln($message);
                }
                array_push($folders, $searchFolder . DIRECTORY_SEPARATOR . $magerunFileContent);
            }
        }
        return $folders;
    }