GrumPHP\Locator\ConfigurationFile::locate PHP Метод

locate() публичный Метод

public locate ( string $workingDir, Composer\Package\PackageInterface $package = null ) : string
$workingDir string
$package Composer\Package\PackageInterface
Результат string
    public function locate($workingDir, PackageInterface $package = null)
    {
        $defaultPath = $workingDir . DIRECTORY_SEPARATOR . self::APP_CONFIG_FILE;
        $defaultPath = $this->locateConfigFileWithDistSupport($defaultPath);
        if (null !== $package) {
            $defaultPath = $this->useConfigPathFromComposer($package, $defaultPath);
        }
        // Make sure to set the full path when it is declared relative
        // This will fix some issues in windows.
        if (!$this->filesystem->isAbsolutePath($defaultPath)) {
            $defaultPath = $workingDir . DIRECTORY_SEPARATOR . $defaultPath;
        }
        return $defaultPath;
    }

Usage Example

Пример #1
0
 /**
  * @return string
  */
 protected function getDefaultConfigPath()
 {
     if ($this->configDefaultPath) {
         return $this->configDefaultPath;
     }
     $locator = new ConfigurationFile($this->filesystem);
     $this->configDefaultPath = $locator->locate(getcwd(), $this->initializeComposerHelper()->getRootPackage());
     return $this->configDefaultPath;
 }