Пример #1
0
 /**
  * Load a collection of extension classes.
  */
 public function addManagedExtensions()
 {
     if ($this->loaded) {
         throw new \RuntimeException(Trans::__('Extensions already loaded.'));
     }
     // Include the extensions autoload file
     if ($this->filesystem->has('vendor/autoload.php') === false) {
         $this->loaded = true;
         return;
     }
     $this->filesystem->includeFile('vendor/autoload.php');
     $descriptors = $this->loadPackageDescriptors();
     foreach ($descriptors as $descriptor) {
         // Skip loading if marked invalid
         if ($descriptor->isValid() === false) {
             continue;
         }
         $this->addManagedExtension($descriptor);
     }
     $this->loaded = true;
 }
Пример #2
0
 /**
  * Searches files and directories which match defined rules.
  *
  * @param string|array $dirs A directory path or an array of directories
  *
  * @throws InvalidArgumentException if one of the directories does not exist
  *
  * @return Finder The current Finder instance
  */
 public function in($dirs)
 {
     $resolvedDirs = [];
     foreach ((array) $dirs as $dir) {
         if ($this->filesystem->has($dir)) {
             $resolvedDirs[] = $dir;
             continue;
         }
         $it = new Iterator\GlobIterator($this->filesystem, $dir);
         $good = false;
         foreach ($it as $item) {
             $good = true;
             if ($item->isDir()) {
                 $resolvedDirs[] = $item->getPath();
             }
         }
         if (!$good) {
             throw new InvalidArgumentException(sprintf('The "%s" directory does not exist.', $dir));
         }
     }
     $this->dirs = array_merge($this->dirs, $resolvedDirs);
     return $this;
 }
Пример #3
0
 /**
  * Gather the 'similar' files, if present.
  *
  * i.e., if we're editing config.yml, we also want to check for
  * config.yml.dist and config_local.yml
  *
  * @param FilesystemInterface $filesystem
  * @param File                $file
  *
  * @return array
  */
 private function getFileGroup(FilesystemInterface $filesystem, File $file)
 {
     $basename = str_replace('.yml', '', str_replace('_local', '', $file->getPath()));
     $filegroup = [];
     if ($filesystem->has($basename . '.yml')) {
         $filegroup[] = basename($basename . '.yml');
     }
     if ($filesystem->has($basename . '_local.yml')) {
         $filegroup[] = basename($basename . '_local.yml');
     }
     return $filegroup;
 }
Пример #4
0
 /**
  * Returns whether the entry exists.
  *
  * @return bool
  */
 public function exists()
 {
     return $this->filesystem->has($this->path);
 }
Пример #5
0
 private function doCopy(FilesystemInterface $fsOrigin, FilesystemInterface $fsTarget, $origin, $target, $override)
 {
     if ($fsTarget->has($target) && ($override === false || $override === null && $fsOrigin->getTimestamp($origin) <= $fsTarget->getTimestamp($target))) {
         return;
     }
     $buffer = $fsOrigin->readStream($origin);
     $fsTarget->putStream($target, $buffer);
     $buffer->close();
 }
Пример #6
0
 /**
  * @internal Do not use
  *
  * @param FilesystemInterface $cacheFs
  * @param string              $environment
  * @param bool                $force
  */
 public function cacheConfig(FilesystemInterface $cacheFs, $environment, $force = false)
 {
     $cacheFileName = $environment . '/config-cache.json';
     if ($cacheFs->has($cacheFileName) && $force === false) {
         return;
     }
     $cacheFile = new JsonFile($cacheFs, $cacheFileName);
     $cacheFile->dump($this->data);
 }
Пример #7
0
 /**
  * {@inheritdoc}
  */
 public function has($file)
 {
     return $this->filesystem->has($file);
 }