-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPageBuilderComponentToShortcodeAction.php
More file actions
40 lines (35 loc) · 1.33 KB
/
PageBuilderComponentToShortcodeAction.php
File metadata and controls
40 lines (35 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/*
* This file is part of the NumberNine package.
*
* (c) William Arin <williamarin.dev@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace NumberNine\Controller\Admin\Api\PageBuilder;
use NumberNine\Content\ArrayToShortcodeConverter;
use NumberNine\Content\ShortcodeMarkupBeautifier;
use NumberNine\Http\ResponseFactory;
use NumberNine\Model\Admin\AdminController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
#[Route(path: 'page_builder/shortcodes/', name: 'numbernine_admin_page_builder_generate_shortcode', options: ['expose' => true], methods: [
'POST',
])]
final class PageBuilderComponentToShortcodeAction implements AdminController
{
public function __invoke(
Request $request,
ResponseFactory $responseFactory,
ArrayToShortcodeConverter $arrayToShortcodeConverter,
ShortcodeMarkupBeautifier $shortcodeMarkupBeautifier
): JsonResponse {
$text = $arrayToShortcodeConverter->convertMany(
[$request->request->all('component')],
(bool) $request->request->get('beautify', false),
);
return $responseFactory->createSerializedJsonResponse($text);
}
}