Skip to content

Commit d8602b3

Browse files
committed
Console: Add proper parent to the created URLs in import-access-url - refs BT#22437
1 parent a0cda2d commit d8602b3

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/CoreBundle/Command/ImportAccessUrlCommand.php

+4-8
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6666
return Command::FAILURE;
6767
}
6868

69-
// Get main AccessUrl (ID = 1) and its ResourceNode
70-
$mainAccessUrl = $this->entityManager->getRepository(AccessUrl::class)->find(1);
69+
// Get main AccessUrl (resource_node.parent = null) and its ResourceNode
70+
$mainAccessUrl = $this->entityManager->getRepository(AccessUrl::class)->findOneBy(['parent' => null]);
7171
if (!$mainAccessUrl) {
72-
$io->error("Main AccessUrl with ID = 1 not found.");
73-
return Command::FAILURE;
74-
}
75-
$parentResourceNode = $mainAccessUrl->getResourceNode();
76-
if (!$parentResourceNode) {
77-
$io->error("Main AccessUrl (ID = 1) has no associated ResourceNode.");
72+
$io->error("Main AccessUrl not found.");
7873
return Command::FAILURE;
7974
}
8075

@@ -145,6 +140,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
145140
//$accessUrl->setResourceNode($resourceNode); // Assign ResourceNode
146141
$accessUrl->addUser($user); // Associate user
147142
$accessUrl->setCreator($user); // Temporary hack as AccessUrl should be able to set this automatically
143+
$accessUrl->setParent($mainAccessUrl); // Set this URL as a child of the admin URL
148144

149145
// Persist entity
150146
$this->entityManager->persist($accessUrl);

0 commit comments

Comments
 (0)