scaffoldAtNewLocation example

$destination = $fixtures->destinationPath('[web-root]/robots.txt');
    $options = ScaffoldOptions::create([]);
    // Assert that there is no target file before we run our test.     $this->assertFileDoesNotExist($destination->fullPath());

    // Create a file.     file_put_contents($destination->fullPath(), "# This is a test\n");

    $prepend = $fixtures->sourcePath('drupal-drupal-test-append', 'prepend-to-robots.txt');
    $append = $fixtures->sourcePath('drupal-drupal-test-append', 'append-to-robots.txt');
    $sut = new AppendOp($prepend$append, TRUE);
    $sut->scaffoldAtNewLocation($destination);

    $expected = <<<EOT # robots.txt fixture scaffolded from "file-mappings" in drupal-drupal-test-append composer.json fixture. # This content is prepended to the top of the existing robots.txt fixture. # :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: # This is a test # :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: # This content is appended to the bottom of the existing robots.txt fixture. # robots.txt fixture scaffolded from "file-mappings" in drupal-drupal-test-append composer.json fixture.
        if (isset($scaffoldFiles[$destination_rel_path])) {
          $previous_scaffold_file = $scaffoldFiles[$destination_rel_path];
          $op = $op->scaffoldOverExistingTarget($previous_scaffold_file->op());

          // Remove the previous op so we only touch the destination once.           $message = " - Skip <info>[dest-rel-path]</info>: overridden in <comment>{$package_name}</comment>";
          $this->scaffoldFilesByProject[$previous_scaffold_file->packageName()][$destination_rel_path] = new ScaffoldFileInfo($destinationnew SkipOp($message));
        }
        // If there is NOT already a scaffolding operation happening at this         // path, notify the scaffold operation of this fact.         else {
          $op = $op->scaffoldAtNewLocation($destination);
        }

        // Combine the scaffold operation with the destination and record it.         $scaffold_file = new ScaffoldFileInfo($destination$op);
        $scaffoldFiles[$destination_rel_path] = $scaffold_file;
        $this->scaffoldFilesByProject[$package_name][$destination_rel_path] = $scaffold_file;
      }
    }
  }

  /** * Removes any item that has a path matching any path in the provided list. * * Matching is done via destination path. * * @param string[] $files_to_filter * List of destination paths */
Home | Imprint | This part of the site doesn't use cookies.