Skip to content

Commit

Permalink
Check $rootResources
Browse files Browse the repository at this point in the history
  • Loading branch information
fogelito committed Aug 6, 2024
1 parent 5b79599 commit 8b98bb4
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Migration/Transfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,19 @@ public function run(
throw new \Exception('Resource type must be set when resource ID is set.');
}

$computedResources = [$rootResourceType];
$rootResources = \array_intersect($computedResources, self::ROOT_RESOURCES);

if (\count($rootResources) > 1) {
throw new \Exception('Multiple root resources found. Only one root resource can be transferred at a time if using $rootResourceId.');
}

if (\count($rootResources) === 0) {
throw new \Exception('No root resources found.');
}

if (\end($rootResources) !== $rootResourceType) {
throw new \Exception('$rootResourceType Does not match');
}
}

$this->resources = $computedResources;
Expand Down

0 comments on commit 8b98bb4

Please sign in to comment.