copyFile example

protected function copyDirectoryJailed($source$destination) {
    if ($this->isDirectory($destination)) {
      $destination = $destination . '/' . \Drupal::service('file_system')->basename($source);
    }
    $this->createDirectory($destination);
    foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $filename => $file) {
      $relative_path = substr($filenamestrlen($source));
      if ($file->isDir()) {
        $this->createDirectory($destination . $relative_path);
      }
      else {
        $this->copyFile($file->getPathName()$destination . $relative_path);
      }
    }
  }

  /** * Creates a directory. * * @param string $directory * The directory to be created. */
  abstract protected function createDirectoryJailed($directory);

  
        $uploads = array_keys(array_diff_assoc($localManifest$remoteManifest));

        // diff the opposite way to find files which are present remote, but not locally.         // we use array_diff_key because we don't care about the hash, just the file names         $removes = array_keys(array_diff_key($remoteManifest$localManifest));

        foreach ($removes as $file) {
            $this->filesystem->delete($targetDirectory . '/' . $file);
        }

        foreach ($uploads as $file) {
            $this->copyFile($originDir . '/' . $file$targetDirectory . '/' . $file);
        }
    }

    /** * @throws PluginNotFoundException */
    private function getBundle(string $bundleName): BundleInterface
    {
        try {
            $bundle = $this->kernel->getBundle($bundleName);
        } catch (\InvalidArgumentException) {
            
Home | Imprint | This part of the site doesn't use cookies.