private function maybeSavePatch()

in src/importit/phase/ImportItSyncPhase.php [224:244]


  private function maybeSavePatch(
    ShipItDestinationRepo $destination_repo,
    ShipItChangeset $changeset,
  ): void {
    $patchesDirectory = $this->patchesDirectory;
    if ($patchesDirectory === null) {
      return;
    }
    if (!PHP\file_exists($patchesDirectory)) {
      PHP\mkdir($patchesDirectory, 0755, /* recursive = */ true);
    } else if (!PHP\is_dir($patchesDirectory)) {
      ShipItLogger::err(
        "Cannot log to %s: the path exists and is not a directory.\n",
        $patchesDirectory,
      );
      return;
    }
    $file = $this->getPatchLocationForChangeset($changeset);
    PHP\file_put_contents($file, $destination_repo::renderPatch($changeset));
    $changeset->withDebugMessage('Saved patch file: %s', $file);
  }