Skip to content

Commit

Permalink
Fix deepcopy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
zonky2 committed Jan 8, 2025
1 parent 00a0cbf commit 9f9bb95
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Contao/Event/Subscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ public function initializePanels(ActionEvent $event): void
if (
!\in_array(
$event->getAction()->getName(),
['copy', 'create', 'paste', 'delete', 'move', 'undo', 'edit', 'toggle', 'showAll', 'show'],
['copy', 'deepcopy', 'create', 'paste', 'delete', 'move', 'undo', 'edit', 'toggle', 'showAll', 'show'],
true
)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function handleEvent(ActionEvent $event)
return;
}

if ('copy' !== $event->getAction()->getName()) {
if (!\in_array($event->getAction()->getName(), ['copy', 'deepcopy'])) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ private function handleCopyAllAction(EnvironmentInterface $environment, Action $
$inputProvider->unsetParameter('source');
}

ViewHelpers::redirectHome($environment);
ViewHelpers::redirectCleanHome($environment, ['select']);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Contao/View/Contao2BackendView/ButtonRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,13 +460,15 @@ private function getChildIds(ModelInterface $model): array
private function calculateParameters(CommandInterface $command, string $serializedModelId): array
{
$parameters = (array) $command->getParameters();

if ($command instanceof ToggleCommandInterface) {
// Toggle has to trigger the javascript.
$parameters['act'] = $command->getName();
$parameters['id'] = $serializedModelId;

return $parameters;
}

if (($command instanceof CutCommandInterface) || ($command instanceof CopyCommandInterface)) {
// Cut & copy need some special information.
if (!\array_key_exists('act', $parameters)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,15 +301,18 @@ private function addToClipboard(ActionEvent $event)
$this->removeItemsFromClipboard($event);

// Only push item to clipboard if manual sorting is used.
if (Item::COPY === $clipboardActionName && null === ViewHelpers::getManualSortingProperty($environment)) {
if (
\in_array($clipboardActionName, [Item::COPY, Item::DEEP_COPY])
&& null === ViewHelpers::getManualSortingProperty($environment)
) {
return;
}

// create the new item
$item = new Item($clipboardActionName, $parentId, $modelId);
}

// If edit several don´t redirect do home and push item to the clipboard.
// If edit several don´t redirect to home and push item to the clipboard.
if ('select' === $input->getParameter('act')) {
$clipboard->push($item)->saveTo($environment);

Expand All @@ -319,7 +322,7 @@ private function addToClipboard(ActionEvent $event)
// Let the clipboard save it's values persistent.
$clipboard->clear()->push($item)->saveTo($environment);

ViewHelpers::redirectHome($environment);
ViewHelpers::redirectCleanHome($environment, ['select']);
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/Contao/View/Contao2BackendView/ViewHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public static function getManualSortingProperty(EnvironmentInterface $environmen
$sort = $panel->getElement('sort');
if ($sort instanceof SortElementInterface) {
$definition = $sort->getSelectedDefinition();
break;
}
}

Expand Down

0 comments on commit 9f9bb95

Please sign in to comment.