Skip to content

Commit

Permalink
fix: code style
Browse files Browse the repository at this point in the history
  • Loading branch information
tikhanovichA committed Jul 26, 2023
1 parent ac60d86 commit d651337
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions models/classes/resources/Service/ClassCopier.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ public function transfer(ResourceTransferCommand $command): ResourceTransferResu
{
$class = $this->ontology->getClass($command->getFrom());
$destinationClass = $this->ontology->getClass($command->getTo());
$copyIdentifier = $this->generateCopyIdentifier($class->getUri(), $destinationClass->getUri());
$newClass = $this->doCopy($class, $destinationClass, $copyIdentifier, $command->keepOriginalAcl());
$newClass = $this->doCopy($class, $destinationClass, $command->keepOriginalAcl());

return new ResourceTransferResult($newClass->getUri());
}
Expand All @@ -91,16 +90,19 @@ public function copy(
core_kernel_classes_Class $class,
core_kernel_classes_Class $destinationClass
): core_kernel_classes_Class {
$copyIdentifier = $this->generateCopyIdentifier($class->getUri(), $destinationClass->getUri());
return $this->doCopy($class, $destinationClass, $copyIdentifier);
return $this->doCopy($class, $destinationClass);
}

private function doCopy(
core_kernel_classes_Class $class,
core_kernel_classes_Class $destinationClass,
string $copyIdentifier,
bool $keepOriginalPermission = true
bool $keepOriginalPermission = true,
string $copyIdentifier = '',
): core_kernel_classes_Class {
// Generate a unique identifier for the copy operation
if (!$copyIdentifier) {
$copyIdentifier = $this->generateCopyIdentifier($class->getUri(), $destinationClass->getUri());
}
// Prevent infinite recursion
if (
isset($this->copiedClasses[$copyIdentifier])
Expand Down Expand Up @@ -141,7 +143,7 @@ private function doCopy(
}

foreach ($class->getSubClasses() as $subClass) {
$this->doCopy($subClass, $newClass, $copyIdentifier, $keepOriginalPermission);
$this->doCopy($subClass, $newClass, $keepOriginalPermission, $copyIdentifier);
}

$this->classMetadataMapper->remove($newClass->getProperties());
Expand Down

0 comments on commit d651337

Please sign in to comment.