1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-29 16:00:15 +02:00

Flextype Box Plugin: Admin #125 #117

- Templates Controller/Views implementation
This commit is contained in:
Awilum
2019-05-28 10:19:39 +03:00
parent 5d36b2329e
commit 2d09c7a3ea

View File

@@ -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'));
}
}