88use RZ \Roadiz \CoreBundle \Entity \Node ;
99use RZ \Roadiz \CoreBundle \Event \Node \NodeCreatedEvent ;
1010use RZ \Roadiz \CoreBundle \Event \Node \NodeDuplicatedEvent ;
11+ use RZ \Roadiz \CoreBundle \Explorer \ExplorerItemFactoryInterface ;
1112use RZ \Roadiz \CoreBundle \Node \NodeDuplicator ;
1213use RZ \Roadiz \CoreBundle \Node \NodeNamePolicyInterface ;
1314use RZ \Roadiz \CoreBundle \Security \Authorization \Voter \NodeVoter ;
1819use Symfony \Component \HttpFoundation \Response ;
1920use Symfony \Component \HttpKernel \Attribute \AsController ;
2021use Symfony \Component \Routing \Attribute \Route ;
22+ use Symfony \Component \String \UnicodeString ;
2123use Symfony \Contracts \EventDispatcher \EventDispatcherInterface ;
2224use Symfony \Contracts \Translation \TranslatorInterface ;
2325
@@ -26,6 +28,7 @@ final class NodeDuplicateController extends AbstractController
2628{
2729 public function __construct (
2830 private readonly NodeNamePolicyInterface $ nodeNamePolicy ,
31+ private readonly ExplorerItemFactoryInterface $ explorerItemFactory ,
2932 private readonly ManagerRegistry $ managerRegistry ,
3033 private readonly EventDispatcherInterface $ eventDispatcher ,
3134 private readonly TranslatorInterface $ translator ,
@@ -53,9 +56,17 @@ public function duplicateAction(
5356 $ form ->handleRequest ($ request );
5457
5558 if (!$ form ->isSubmitted () || !$ form ->isValid ()) {
56- return $ this ->render ('@RoadizRozier/nodes/duplicate.html.twig ' , [
57- 'node ' => $ existingNode ,
59+ return $ this ->render ('@RoadizRozier/admin/confirm_action.html.twig ' , [
60+ 'title ' => new UnicodeString ($ this ->translator ->trans ('duplicate.node ' )),
61+ 'headPath ' => '@RoadizRozier/nodes/head.html.twig ' ,
62+ 'cancelPath ' => $ this ->generateUrl ('nodesEditPage ' , ['nodeId ' => $ existingNode ->getId ()]),
63+ 'alertMessage ' => 'are_you_sure.duplicate.node ' ,
64+ 'messageType ' => 'warning ' ,
65+ 'action_color ' => 'success ' ,
66+ 'action_label ' => $ this ->translator ->trans ('duplicate ' ),
67+ 'action_icon ' => 'rz-icon-ri--file-copy-line ' ,
5868 'form ' => $ form ->createView (),
69+ 'items ' => [$ this ->explorerItemFactory ->createForEntity ($ existingNode )->toArray ()],
5970 ]);
6071 }
6172
0 commit comments