From 2d09c7a3ea2a42049112cf389e94823235350901 Mon Sep 17 00:00:00 2001 From: Awilum Date: Tue, 28 May 2019 10:19:39 +0300 Subject: [PATCH] Flextype Box Plugin: Admin #125 #117 - Templates Controller/Views implementation --- .../admin/app/Controllers/TemplatesController.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/site/plugins/admin/app/Controllers/TemplatesController.php b/site/plugins/admin/app/Controllers/TemplatesController.php index f6eefcc6..806c2e27 100644 --- a/site/plugins/admin/app/Controllers/TemplatesController.php +++ b/site/plugins/admin/app/Controllers/TemplatesController.php @@ -2,6 +2,7 @@ namespace Flextype; +use Flextype\Component\Filesystem\Filesystem; use function Flextype\Component\I18n\__; class TemplatesController extends Controller @@ -67,6 +68,15 @@ class TemplatesController extends Controller public function duplicateProcess($request, $response, $args) { + $template_path = PATH['themes'] . '/' . $this->registry->get('settings.theme') . '/templates/' . $request->getParsedBody()['template-id'] . '.html'; + $template_path_new = PATH['themes'] . '/' . $this->registry->get('settings.theme') . '/templates/' . $request->getParsedBody()['template-id'] . '-duplicate-' . date("Ymd_His") . '.html'; + if (Filesystem::copy($template_path, $template_path_new)) { + $this->flash->addMessage('success', __('admin_message_templates_duplicated')); + } else { + $this->flash->addMessage('error', __('admin_message_templates_was_not_duplicated')); + } + + return $response->withRedirect($this->container->get('router')->pathFor('admin.templates.index')); } }