mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
add ordering to social issue and social action
This commit is contained in:
@@ -253,6 +253,8 @@ final class SocialWorkMetadata implements SocialWorkMetadataInterface
|
||||
?string $socialActionTitle,
|
||||
?string $socialActionChildTitle,
|
||||
SocialIssue $socialIssue,
|
||||
float $orderingParent,
|
||||
float $orderingChild,
|
||||
?SocialAction $previousSocialAction,
|
||||
?SocialAction $previousSocialActionChild
|
||||
): array {
|
||||
@@ -271,7 +273,8 @@ final class SocialWorkMetadata implements SocialWorkMetadataInterface
|
||||
];
|
||||
$parentIsSame = true;
|
||||
} else {
|
||||
$return['socialAction'] = $parent = (new SocialAction())->setTitle(['fr' => $socialActionTitle]);
|
||||
$return['socialAction'] = $parent = (new SocialAction())->setTitle(['fr' => $socialActionTitle])
|
||||
->setOrdering($orderingParent);
|
||||
$parent->setIssue($socialIssue);
|
||||
$this->entityManager->persist($parent);
|
||||
$parentIsSame = false;
|
||||
@@ -284,7 +287,7 @@ final class SocialWorkMetadata implements SocialWorkMetadataInterface
|
||||
} else {
|
||||
$return['socialActionChild'] = $child = (new SocialAction())->setTitle(['fr' => $socialActionChildTitle]);
|
||||
$parent->addChild($child);
|
||||
$child->setIssue($socialIssue);
|
||||
$child->setIssue($socialIssue)->setOrdering($orderingChild);
|
||||
$this->entityManager->persist($child);
|
||||
}
|
||||
|
||||
@@ -299,6 +302,8 @@ final class SocialWorkMetadata implements SocialWorkMetadataInterface
|
||||
private function handleSocialIssue(
|
||||
?string $socialIssueTitle,
|
||||
?string $socialIssueChildTitle,
|
||||
float $orderingParent,
|
||||
float $orderingChild,
|
||||
?SocialIssue $previousSocialIssue,
|
||||
?SocialIssue $previousSocialIssueChild
|
||||
): array {
|
||||
@@ -310,7 +315,8 @@ final class SocialWorkMetadata implements SocialWorkMetadataInterface
|
||||
];
|
||||
$parentIsSame = true;
|
||||
} elseif (null !== $socialIssueTitle) {
|
||||
$return['socialIssue'] = $parent = (new SocialIssue())->setTitle(['fr' => $socialIssueTitle]);
|
||||
$return['socialIssue'] = $parent = (new SocialIssue())->setTitle(['fr' => $socialIssueTitle])
|
||||
->setOrdering($orderingParent);
|
||||
$this->entityManager->persist($parent);
|
||||
$parentIsSame = false;
|
||||
} else {
|
||||
@@ -323,7 +329,8 @@ final class SocialWorkMetadata implements SocialWorkMetadataInterface
|
||||
if ($parentIsSame && null !== $previousSocialIssueChild && ($previousSocialIssueChild->getTitle()['fr'] === $socialIssueChildTitle)) {
|
||||
$return['socialIssueChild'] = $previousSocialIssueChild;
|
||||
} elseif (null !== $socialIssueChildTitle) {
|
||||
$return['socialIssueChild'] = $child = (new SocialIssue())->setTitle(['fr' => $socialIssueChildTitle]);
|
||||
$return['socialIssueChild'] = $child = (new SocialIssue())->setTitle(['fr' => $socialIssueChildTitle])
|
||||
->setOrdering($orderingChild);
|
||||
$parent->addChild($child);
|
||||
$this->entityManager->persist($child);
|
||||
} else {
|
||||
@@ -353,10 +360,14 @@ final class SocialWorkMetadata implements SocialWorkMetadataInterface
|
||||
*/
|
||||
private function import1(int $key, array $row, array $previousRow): array
|
||||
{
|
||||
$baseOrdering = $key * 10.0;
|
||||
|
||||
$socialIssues = $this
|
||||
->handleSocialIssue(
|
||||
$row[0],
|
||||
$row[1],
|
||||
$key + 1.0,
|
||||
$key + 3.0,
|
||||
$previousRow['socialIssues']['socialIssue'] ?? null,
|
||||
$previousRow['socialIssues']['socialIssueChild'] ?? null
|
||||
);
|
||||
@@ -372,6 +383,8 @@ final class SocialWorkMetadata implements SocialWorkMetadataInterface
|
||||
$row[2],
|
||||
$row[3],
|
||||
$socialIssue,
|
||||
$key + 5.0,
|
||||
$key + 7.0,
|
||||
$previousRow['socialActions']['socialAction'] ?? null,
|
||||
$previousRow['socialActions']['socialActionChild'] ?? null
|
||||
);
|
||||
|
Reference in New Issue
Block a user