Issues (3627)

MauticFocusBundle/Controller/AjaxController.php (1 issue)

1
<?php
2
3
/*
4
 * @copyright   2016 Mautic, Inc. All rights reserved
5
 * @author      Mautic, Inc
6
 *
7
 * @link        https://mautic.org
8
 *
9
 * @license     GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
10
 */
11
12
namespace MauticPlugin\MauticFocusBundle\Controller;
13
14
use Mautic\CoreBundle\Controller\AjaxController as CommonAjaxController;
15
use Mautic\CoreBundle\Helper\InputHelper;
16
use MauticPlugin\MauticFocusBundle\Helper\IframeAvailabilityChecker;
17
use MauticPlugin\MauticFocusBundle\Model\FocusModel;
18
use Symfony\Component\HttpFoundation\JsonResponse;
19
use Symfony\Component\HttpFoundation\Request;
20
21
class AjaxController extends CommonAjaxController
22
{
23
    /**
24
     * This method produces HTTP request checking headers which are blocking availability for iframe inheritance for other pages.
25
     */
26
    protected function checkIframeAvailabilityAction(Request $request): JsonResponse
27
    {
28
        $url = $request->request->get('website');
29
30
        /** @var IframeAvailabilityChecker $availabilityChecker */
31
        $availabilityChecker = $this->get('mautic.focus.helper.iframe_availability_checker');
32
33
        return $availabilityChecker->check($url, $request->getScheme());
34
    }
35
36
    protected function generatePreviewAction(Request $request): JsonResponse
37
    {
38
        $responseContent  = ['html' => '', 'style' => ''];
39
        $focus            = $request->request->all();
40
41
        if (isset($focus['focus'])) {
42
            $focusArray = InputHelper::_($focus['focus']);
43
44
            if (!empty($focusArray['style']) && !empty($focusArray['type'])) {
45
                /** @var FocusModel $model */
46
                $model                    = $this->getModel('focus');
47
                $focusArray['id']         = 'preview';
48
                $responseContent['html']  = $model->getContent($focusArray, true);
0 ignored issues
show
It seems like $focusArray can also be of type string; however, parameter $focus of MauticPlugin\MauticFocus...ocusModel::getContent() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

48
                $responseContent['html']  = $model->getContent(/** @scrutinizer ignore-type */ $focusArray, true);
Loading history...
49
                $responseContent['style'] = $focusArray['style']; // Required by JS in response
50
            }
51
        }
52
53
        return $this->sendJsonResponse($responseContent);
54
    }
55
}
56