From ec3806d818c5476aa6002bc96041eb3f490dba8c Mon Sep 17 00:00:00 2001 From: Ingolf Steinhardt Date: Wed, 11 Sep 2024 20:36:57 +0200 Subject: [PATCH] Fix copy item in tree view - before wie have a "move" instead of copy --- src/Contao/View/Contao2BackendView/ButtonRenderer.php | 4 +++- src/Contao/View/Contao2BackendView/TreeView.php | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Contao/View/Contao2BackendView/ButtonRenderer.php b/src/Contao/View/Contao2BackendView/ButtonRenderer.php index cb0532ed..962486d1 100644 --- a/src/Contao/View/Contao2BackendView/ButtonRenderer.php +++ b/src/Contao/View/Contao2BackendView/ButtonRenderer.php @@ -54,6 +54,7 @@ use ContaoCommunityAlliance\DcGeneral\Exception\DcGeneralInvalidArgumentException; use ContaoCommunityAlliance\DcGeneral\InputProviderInterface; use ContaoCommunityAlliance\Translator\TranslatorInterface; +use ContaoCommunityAlliance\UrlBuilder\UrlBuilder; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use function array_filter; @@ -232,7 +233,8 @@ private function renderButtonsFor( if ($this->hasPasteButtons()) { $urlAfter = $this->addToUrl(sprintf('act=paste&after=%s&', $modelId)); $urlInto = $this->addToUrl(sprintf('act=paste&into=%s&', $modelId)); - + $urlAfter = UrlBuilder::fromUrl($urlAfter)->unsetQueryParameter('source')->getUrl(); + $urlInto = UrlBuilder::fromUrl($urlInto)->unsetQueryParameter('source')->getUrl(); $buttonEvent = new GetPasteButtonEvent($this->environment); $buttonEvent diff --git a/src/Contao/View/Contao2BackendView/TreeView.php b/src/Contao/View/Contao2BackendView/TreeView.php index b7c3e513..6e8b39bf 100644 --- a/src/Contao/View/Contao2BackendView/TreeView.php +++ b/src/Contao/View/Contao2BackendView/TreeView.php @@ -60,6 +60,7 @@ use ContaoCommunityAlliance\DcGeneral\Panel\SortElementInterface; use ContaoCommunityAlliance\DcGeneral\SessionStorageInterface; use ContaoCommunityAlliance\Translator\TranslatorInterface; +use ContaoCommunityAlliance\UrlBuilder\UrlBuilder; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; @@ -606,9 +607,11 @@ protected function viewTree($collection) ContaoEvents::BACKEND_ADD_TO_URL ); + $urlInto = UrlBuilder::fromUrl($urlEvent->getUrl())->unsetQueryParameter('source')->getUrl(); + $buttonEvent = new GetPasteRootButtonEvent($environment); $buttonEvent - ->setHref($urlEvent->getUrl()) + ->setHref($urlInto) ->setPasteDisabled(false); $dispatcher->dispatch($buttonEvent, $buttonEvent::NAME);