getConfig() public méthode

Get the application's configuration, parsed from its YAML definition.
public getConfig ( ) : array
Résultat array
 public function testGetAppConfigNested()
 {
     $fakeAppRoot = 'tests/data/repositories/multiple/nest/nested';
     $app = new LocalApplication($fakeAppRoot);
     $config = $app->getConfig();
     $this->assertEquals(['name' => 'nested1'], $config);
     $this->assertEquals('nested1', $app->getName());
     $this->assertEquals('nested1', $app->getId());
 }
 /**
  * @param LocalApplication $app
  * @param string           $sourceDir
  * @param string           $destination
  *
  * @return bool
  */
 protected function buildApp($app, $sourceDir, $destination)
 {
     $verbose = $this->output->isVerbose();
     $appRoot = $app->getRoot();
     $appConfig = $app->getConfig();
     $multiApp = $appRoot != $sourceDir;
     $appName = $app->getName();
     $appId = $app->getId();
     $buildName = date('Y-m-d--H-i-s');
     if (!empty($this->settings['environmentId'])) {
         $buildName .= '--' . $this->settings['environmentId'];
     }
     if ($multiApp) {
         $buildName .= '--' . str_replace('/', '-', $appId);
     }
     if (!empty($this->settings['projectRoot'])) {
         $buildDir = $this->settings['projectRoot'] . '/' . LocalProject::BUILD_DIR . '/' . $buildName;
     } else {
         $buildDir = $sourceDir . '/' . LocalProject::BUILD_DIR . '/' . $buildName;
     }
     // Get the configured document root.
     $documentRoot = $this->getDocumentRoot($appConfig);
     $toolstack = $app->getToolstack();
     if (!$toolstack) {
         $this->output->writeln("Toolstack not found for application <error>{$appId}</error>");
         return false;
     }
     // Warn about a mismatched PHP version.
     if (isset($appConfig['type']) && strpos($appConfig['type'], ':')) {
         list($stack, $version) = explode(':', $appConfig['type'], 2);
         if ($stack === 'php' && version_compare($version, PHP_VERSION, '>')) {
             $this->output->writeln(sprintf('<comment>Warning:</comment> the application <comment>%s</comment> expects PHP %s, but the system version is %s.', $appId, $version, PHP_VERSION));
         }
     }
     $toolstack->setOutput($this->output);
     $buildSettings = $this->settings + ['multiApp' => $multiApp, 'appName' => $appName];
     $toolstack->prepare($buildDir, $documentRoot, $appRoot, $buildSettings);
     $archive = false;
     if (empty($this->settings['noArchive']) && empty($this->settings['noCache']) && !empty($this->settings['projectRoot'])) {
         $treeId = $this->getTreeId($appRoot);
         if ($treeId) {
             if ($verbose) {
                 $this->output->writeln("Tree ID: {$treeId}");
             }
             $archive = $this->settings['projectRoot'] . '/' . LocalProject::ARCHIVE_DIR . '/' . $treeId . '.tar.gz';
         }
     }
     if ($archive && file_exists($archive)) {
         $message = "Extracting archive for application <info>{$appId}</info>";
         $this->output->writeln($message);
         $this->fsHelper->extractArchive($archive, $buildDir);
     } else {
         $message = "Building application <info>{$appId}</info>";
         if (isset($appConfig['type'])) {
             $message .= ' (runtime type: ' . $appConfig['type'] . ')';
         }
         $this->output->writeln($message);
         $toolstack->build();
         if ($this->runPostBuildHooks($appConfig, $toolstack->getAppRoot()) === false) {
             // The user may not care if build hooks fail, but we should
             // not archive the result.
             $archive = false;
         }
         if ($archive && $toolstack->canArchive()) {
             $this->output->writeln("Saving build archive");
             if (!is_dir(dirname($archive))) {
                 mkdir(dirname($archive));
             }
             $this->fsHelper->archiveDir($buildDir, $archive);
         }
     }
     $toolstack->install();
     $webRoot = $toolstack->getWebRoot();
     // Symlink the built web root ($webRoot) into www or www/appId.
     if (!is_dir($webRoot)) {
         $this->output->writeln("Web root not found: <error>{$webRoot}</error>");
         return false;
     }
     if ($multiApp) {
         $appDir = str_replace('/', '-', $appId);
         if (is_link($destination)) {
             $this->fsHelper->remove($destination);
         }
         $destination .= "/{$appDir}";
     }
     $this->fsHelper->symlink($webRoot, $destination);
     $this->output->writeln("Web root: {$destination}");
     $message = "Build complete for application <info>{$appId}</info>";
     $this->output->writeln($message);
     return true;
 }
 /**
  * @param LocalApplication $app
  * @param string           $sourceDir
  * @param string           $destination
  *
  * @return bool
  */
 protected function buildApp($app, $sourceDir, $destination = null)
 {
     $verbose = $this->output->isVerbose();
     $destination = $destination ?: $sourceDir . '/' . $this->config->get('local.web_root');
     $appRoot = $app->getRoot();
     $appConfig = $app->getConfig();
     $multiApp = $appRoot != $sourceDir;
     $appId = $app->getId();
     $toolstack = $app->getToolstack();
     if (!$toolstack) {
         $this->output->writeln("Toolstack not found for application <error>{$appId}</error>");
         return false;
     }
     // Find the right build directory.
     $buildName = $multiApp ? str_replace('/', '-', $appId) : 'default';
     $tmpBuildDir = $sourceDir . '/' . $this->config->get('local.build_dir') . '/' . $buildName . '-tmp';
     if (file_exists($tmpBuildDir)) {
         if (!$this->fsHelper->remove($tmpBuildDir)) {
             $this->output->writeln(sprintf('Failed to remove directory <error>%s</error>', $tmpBuildDir));
             return false;
         }
     }
     // If the destination is inside the source directory, ensure it isn't
     // copied or symlinked into the build.
     if (strpos($destination, $sourceDir) === 0) {
         $toolstack->addIgnoredFiles([ltrim(substr($destination, strlen($sourceDir)), '/')]);
     }
     // Warn about a mismatched PHP version.
     if (isset($appConfig['type']) && strpos($appConfig['type'], ':')) {
         list($stack, $version) = explode(':', $appConfig['type'], 2);
         if ($stack === 'php' && version_compare($version, PHP_VERSION, '>')) {
             $this->output->writeln(sprintf('<comment>Warning:</comment> the application <comment>%s</comment> expects PHP %s, but the system version is %s.', $appId, $version, PHP_VERSION));
         }
     }
     $toolstack->setOutput($this->output);
     $buildSettings = $this->settings + ['multiApp' => $multiApp, 'sourceDir' => $sourceDir];
     $toolstack->prepare($tmpBuildDir, $app, $this->config, $buildSettings);
     $archive = false;
     if (empty($this->settings['no-archive']) && empty($this->settings['no-cache'])) {
         $treeId = $this->getTreeId($appRoot);
         if ($treeId) {
             if ($verbose) {
                 $this->output->writeln("Tree ID: {$treeId}");
             }
             $archive = $sourceDir . '/' . $this->config->get('local.archive_dir') . '/' . $treeId . '.tar.gz';
         }
     }
     if ($archive && file_exists($archive)) {
         $message = "Extracting archive for application <info>{$appId}</info>";
         $this->output->writeln($message);
         $this->fsHelper->extractArchive($archive, $tmpBuildDir);
     } else {
         $message = "Building application <info>{$appId}</info>";
         if (isset($appConfig['type'])) {
             $message .= ' (runtime type: ' . $appConfig['type'] . ')';
         }
         $this->output->writeln($message);
         $toolstack->build();
         if ($this->runPostBuildHooks($appConfig, $toolstack->getAppDir()) === false) {
             // The user may not care if build hooks fail, but we should
             // not archive the result.
             $archive = false;
         }
         if ($archive && $toolstack->canArchive()) {
             $this->output->writeln("Saving build archive");
             if (!is_dir(dirname($archive))) {
                 mkdir(dirname($archive));
             }
             $this->fsHelper->archiveDir($tmpBuildDir, $archive);
         }
     }
     // The build is complete. Move the directory.
     $buildDir = substr($tmpBuildDir, 0, strlen($tmpBuildDir) - 4);
     if (file_exists($buildDir)) {
         if (empty($this->settings['no-backup']) && is_dir($buildDir) && !is_link($buildDir)) {
             $previousBuildArchive = dirname($buildDir) . '/' . basename($buildDir) . '-old.tar.gz';
             $this->output->writeln("Backing up previous build to: " . $previousBuildArchive);
             $this->fsHelper->archiveDir($buildDir, $previousBuildArchive);
         }
         if (!$this->fsHelper->remove($buildDir, true)) {
             $this->output->writeln(sprintf('Failed to remove directory <error>%s</error>', $buildDir));
             return false;
         }
     }
     if (!rename($tmpBuildDir, $buildDir)) {
         $this->output->writeln(sprintf('Failed to move temporary build directory into <error>%s</error>', $buildDir));
         return false;
     }
     $toolstack->setBuildDir($buildDir);
     $toolstack->install();
     $this->runPostDeployHooks($appConfig, $buildDir);
     $webRoot = $toolstack->getWebRoot();
     // Symlink the built web root ($webRoot) into www or www/appId.
     if (!is_dir($webRoot)) {
         $this->output->writeln("\nWeb root not found: <error>{$webRoot}</error>\n");
         return false;
     }
     if ($multiApp) {
         $appDir = str_replace('/', '-', $appId);
         if (is_link($destination)) {
             $this->fsHelper->remove($destination);
         }
         $destination .= "/{$appDir}";
     }
     $this->fsHelper->symlink($webRoot, $destination);
     $message = "\nBuild complete for application <info>{$appId}</info>";
     $this->output->writeln($message);
     $this->output->writeln("Web root: <info>{$destination}</info>\n");
     return true;
 }
 /**
  * @param Environment $environment
  * @param LocalApplication $app
  * @param bool $multiApp
  *
  * @return array|false
  */
 protected function generateRemoteAlias($environment, $app, $multiApp = false)
 {
     if (!$environment->hasLink('ssh') || !$environment->hasLink('public-url')) {
         return false;
     }
     $sshUrl = parse_url($environment->getLink('ssh'));
     if (!$sshUrl) {
         return false;
     }
     $sshUser = $sshUrl['user'];
     if ($multiApp) {
         $sshUser .= '--' . $app->getName();
     }
     $uri = $environment->getLink('public-url');
     if ($multiApp) {
         $guess = str_replace('http://', 'http://' . $app->getName() . '---', $uri);
         if (in_array($guess, $environment->getRouteUrls())) {
             $uri = $guess;
         }
     }
     $appConfig = $app->getConfig();
     $documentRoot = '/public';
     if (isset($appConfig['web']['document_root']) && $appConfig['web']['document_root'] !== '/') {
         $documentRoot = $appConfig['web']['document_root'];
     }
     return ['uri' => $uri, 'remote-host' => $sshUrl['host'], 'remote-user' => $sshUser, 'root' => '/app/' . ltrim($documentRoot, '/'), self::AUTO_REMOVE_KEY => true, 'command-specific' => ['site-install' => ['sites-subdir' => 'default']]];
 }