/** * Process the defined special destinations. */ protected function processSpecialDestinations() { foreach ($this->specialDestinations as $sourcePattern => $relDestination) { $matched = glob($this->appRoot . '/' . $sourcePattern, GLOB_NOSORT); if (!$matched) { continue; } if ($relDestination === '{webroot}' && $this->buildInPlace) { continue; } // On Platform these replacements would be a bit different. $absDestination = str_replace(['{webroot}', '{approot}'], [$this->getWebRoot(), $this->buildDir], $relDestination); foreach ($matched as $source) { // Ignore the source if it's in ignoredFiles. $relSource = str_replace($this->appRoot . '/', '', $source); if (in_array($relSource, $this->ignoredFiles)) { continue; } $destination = $absDestination; // Do not overwrite directories with files. if (!is_dir($source) && is_dir($destination)) { $destination = $destination . '/' . basename($source); } // Ignore if source and destination are the same. if ($destination === $source) { continue; } if ($this->copy) { $this->output->writeln("Copying {$relSource} to {$relDestination}"); } else { $this->output->writeln("Symlinking {$relSource} to {$relDestination}"); } // Delete existing files, emitting a warning. if (file_exists($destination)) { $this->output->writeln(sprintf("Overriding existing path '%s' in destination", str_replace($this->buildDir . '/', '', $destination))); $this->fsHelper->remove($destination); } if ($this->copy) { $this->fsHelper->copy($source, $destination); } else { $this->fsHelper->symlink($source, $destination); } } } }
/** * Create a settings.local.php for a Drupal site. * * This helps with database setup, etc. */ protected function installDrupalSettingsLocal() { $sitesDefault = $this->getWebRoot() . '/sites/default'; $shared = $this->getSharedDir(); $settingsLocal = $sitesDefault . '/settings.local.php'; if ($shared !== false && is_dir($sitesDefault) && !file_exists($settingsLocal)) { $sharedSettingsLocal = $shared . '/settings.local.php'; $relative = $this->config->get('local.shared_dir') . '/settings.local.php'; if (!file_exists($sharedSettingsLocal)) { $this->output->writeln("Creating file: <info>{$relative}</info>"); $this->fsHelper->copy(CLI_ROOT . '/resources/drupal/settings.local.php.dist', $sharedSettingsLocal); $this->output->writeln('Edit this file to add your database credentials and other Drupal configuration.'); } else { $this->output->writeln("Symlinking <info>{$relative}</info> into sites/default"); } $this->fsHelper->symlink($sharedSettingsLocal, $settingsLocal); } }