Spaces:
No application file
No application file
File size: 3,062 Bytes
d2897cd |
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
<?php
namespace Mautic\PointBundle\Controller;
use Mautic\CoreBundle\Controller\AjaxController as CommonAjaxController;
use Mautic\CoreBundle\Helper\InputHelper;
use Mautic\PointBundle\Form\Type\GenericPointSettingsType;
use Mautic\PointBundle\Form\Type\PointActionType;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\Request;
class AjaxController extends CommonAjaxController
{
public function reorderTriggerEventsAction(Request $request): \Symfony\Component\HttpFoundation\JsonResponse
{
$dataArray = ['success' => 0];
$session = $request->getSession();
$triggerId = InputHelper::clean($request->request->get('triggerId'));
$sessionName = 'mautic.point.'.$triggerId.'.triggerevents.modified';
$order = InputHelper::clean($request->request->get('triggerEvent'));
$components = $session->get($sessionName);
if (!empty($order) && !empty($components)) {
$components = array_replace(array_flip($order), $components);
$session->set($sessionName, $components);
$dataArray['success'] = 1;
}
return $this->sendJsonResponse($dataArray);
}
public function getActionFormAction(Request $request, FormFactoryInterface $formFactory): \Symfony\Component\HttpFoundation\JsonResponse
{
$dataArray = [
'success' => 0,
'html' => '',
];
$type = InputHelper::clean($request->request->get('actionType'));
if (!empty($type)) {
// get the HTML for the form
/** @var \Mautic\PointBundle\Model\PointModel $model */
$model = $this->getModel('point');
$actions = $model->getPointActions();
if (isset($actions['actions'][$type])) {
$themes = ['@MauticPoint/FormTheme/Action/_pointaction_properties_row.html.twig'];
if (!empty($actions['actions'][$type]['formTheme'])) {
$themes[] = $actions['actions'][$type]['formTheme'];
}
$formType = (!empty($actions['actions'][$type]['formType'])) ? $actions['actions'][$type]['formType'] : GenericPointSettingsType::class;
$formTypeOptions = (!empty($actions['actions'][$type]['formTypeOptions'])) ? $actions['actions'][$type]['formTypeOptions'] : [];
$form = $formFactory->create(PointActionType::class, [], ['formType' => $formType, 'formTypeOptions' => $formTypeOptions]);
$html = $this->renderView('@MauticPoint/Point/actionform.html.twig', [
'form' => $form->createView(),
'formThemes' => $themes,
]);
// replace pointaction with point
$html = str_replace('pointaction', 'point', $html);
$dataArray['html'] = $html;
$dataArray['success'] = 1;
}
}
return $this->sendJsonResponse($dataArray);
}
}
|