getSharedFileMounts() public method

Get a list of shared file mounts configured for the app.
public getSharedFileMounts ( ) : array
return array An array of shared file mount paths, keyed by the path in the app. Leading and trailing slashes are stripped.
Ejemplo n.º 1
0
 /**
  * Process shared file mounts in the application.
  *
  * For each "mount", this creates a corresponding directory in the project's
  * shared files directory, and symlinks it into the appropriate path in the
  * build.
  */
 protected function processSharedFileMounts()
 {
     $sharedDir = $this->getSharedDir();
     if ($sharedDir === false) {
         return;
     }
     // If the build directory is a symlink, then skip, so that we don't risk
     // modifying the user's repository.
     if (is_link($this->buildDir)) {
         return;
     }
     $sharedFileMounts = $this->app->getSharedFileMounts();
     if (empty($sharedFileMounts)) {
         return;
     }
     $sharedDirRelative = $this->config->get('local.shared_dir');
     $this->output->writeln('Creating symbolic links to mimic shared file mounts');
     foreach ($sharedFileMounts as $appPath => $sharedPath) {
         $target = $sharedDir . '/' . $sharedPath;
         $targetRelative = $sharedDirRelative . '/' . $sharedPath;
         $link = $this->buildDir . '/' . $appPath;
         if (file_exists($link) && !is_link($link)) {
             $this->output->writeln('  Overwriting existing file <comment>' . $appPath . '</comment>');
         }
         if (!file_exists($target)) {
             $this->fsHelper->mkdir($target, 0775);
         }
         $this->output->writeln('  Symlinking <info>' . $appPath . '</info> to <info>' . $targetRelative . '</info>');
         $this->fsHelper->symlink($target, $link);
     }
 }
 public function testGetSharedFileMounts()
 {
     $appRoot = 'tests/data/apps/drupal/project';
     $app = new LocalApplication($appRoot);
     $this->assertEquals(['public/sites/default/files' => 'files', 'tmp' => 'tmp', 'private' => 'private', 'drush-backups' => 'drush-backups'], $app->getSharedFileMounts());
 }