Spaces:
No application file
No application file
File size: 1,989 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 |
<?php
namespace MauticPlugin\MauticSocialBundle\Controller;
use Mautic\CoreBundle\Controller\AjaxController as CommonAjaxController;
use Mautic\CoreBundle\Controller\AjaxLookupControllerTrait;
use Mautic\CoreBundle\Helper\InputHelper;
use MauticPlugin\MauticSocialBundle\Model\MonitoringModel;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\Request;
class AjaxController extends CommonAjaxController
{
use AjaxLookupControllerTrait;
public function getNetworkFormAction(Request $request, MonitoringModel $monitoringModel, FormFactoryInterface $formFactory): \Symfony\Component\HttpFoundation\JsonResponse
{
// get the form type
$type = InputHelper::clean($request->request->get('networkType'));
// default to empty
$dataArray = [
'html' => '',
'success' => 0,
];
if (!empty($type)) {
// get the HTML for the form
$formType = $monitoringModel->getFormByType($type);
// get the network type form
$form = $formFactory->create($formType, [], ['label' => false, 'csrf_protection' => false]);
$html = $this->renderView(
'@MauticSocial/FormTheme/'.$type.'_widget.html.twig',
['form' => $form->createView()]
);
$html = str_replace(
[
$type.'[', // this is going to generate twitter_hashtag[ or twitter_mention[
$type.'_', // this is going to generate twitter_hashtag_ or twitter_mention_
$type,
],
[
'monitoring[properties][',
'monitoring_properties_',
'monitoring',
],
$html
);
$dataArray['html'] = $html;
$dataArray['success'] = 1;
}
return $this->sendJsonResponse($dataArray);
}
}
|