getName() public method

public getName ( ) : string | null
return string | null
 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());
 }
 /**
  * Get the directory containing files shared between builds.
  *
  * This will be 'shared' for a single-application project, or
  * 'shared/<appName>' when there are multiple applications.
  *
  * @return string|false
  */
 protected function getSharedDir()
 {
     if (empty($this->settings['sourceDir'])) {
         return false;
     }
     $shared = $this->settings['sourceDir'] . '/' . $this->config->get('local.shared_dir');
     if (!empty($this->settings['multiApp'])) {
         $shared .= '/' . preg_replace('/[^a-z0-9\\-_]+/i', '-', $this->app->getName());
     }
     $this->fsHelper->mkdir($shared);
     return $shared;
 }
 /**
  * @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;
 }
Example #4
0
 /**
  * @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']]];
 }
 /**
  * @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;
         }
     }
     return ['uri' => $uri, 'remote-host' => $sshUrl['host'], 'remote-user' => $sshUser, 'root' => '/app/' . $app->getDocumentRoot(), $this->getAutoRemoveKey() => true, 'command-specific' => ['site-install' => ['sites-subdir' => 'default']]];
 }