N98\Magento\Application\ConfigLocator::getUserConfigFile PHP Method

getUserConfigFile() public method

Obtain the user-config-file, it is placed in the homedir, e.g. ~/.n98-magerun2.yaml
public getUserConfigFile ( ) : ConfigFile | null
return ConfigFile | null
    public function getUserConfigFile()
    {
        $userConfigFile = null;
        $personalConfigFilePaths = $this->getUserConfigFilePaths();
        foreach ($personalConfigFilePaths as $personalConfigFilePath) {
            try {
                $userConfigFile = ConfigFile::createFromFile($personalConfigFilePath);
                $userConfigFile->applyVariables($this->magentoRootFolder);
                break;
            } catch (InvalidArgumentException $e) {
                $userConfigFile = null;
            }
        }
        return $userConfigFile;
    }

Usage Example

 /**
  * Check if there is a user config file. ~/.n98-magerun.yaml
  *
  * @param array $config
  * @param string|null $magentoRootFolder [optional]
  *
  * @return array
  */
 public function loadUserConfig(array $config, $magentoRootFolder = null)
 {
     if (null === $this->_userConfig) {
         $this->_userConfig = array();
         $locator = new ConfigLocator($this->_customConfigFilename, $magentoRootFolder);
         if ($userConfigFile = $locator->getUserConfigFile()) {
             $this->_userConfig = $userConfigFile->toArray();
         }
     }
     $config = ArrayFunctions::mergeArrays($config, $this->_userConfig);
     return $config;
 }