Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deepcopy issues #663

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading