Issues (3627)

app/bundles/CoreBundle/Event/CustomAssetsEvent.php (1 issue)

1
<?php
2
3
/*
4
 * @copyright   2016 Mautic Contributors. 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 Mautic\CoreBundle\Event;
13
14
use Mautic\CoreBundle\Templating\Helper\AssetsHelper;
15
use Symfony\Component\EventDispatcher\Event;
16
17
/**
18
 * Class CustomAssetsEvent.
19
 */
20
class CustomAssetsEvent extends Event
21
{
22
    /**
23
     * @var AssetsHelper
24
     */
25
    protected $assetsHelper;
26
27
    /**
28
     * CustomAssetsEvent constructor.
29
     */
30
    public function __construct(AssetsHelper $assetsHelper)
31
    {
32
        $this->assetsHelper = $assetsHelper;
33
    }
34
35
    /**
36
     * @param        $declaration
37
     * @param string $location
38
     * @param string $context
39
     */
40
    public function addCustomDeclaration($declaration, $location = 'head', $context = AssetsHelper::CONTEXT_APP)
41
    {
42
        $this->assetsHelper->setContext($context)
43
            ->addCustomDeclaration($declaration, $location)
44
            ->setContext(AssetsHelper::CONTEXT_APP);
45
46
        return $this;
47
    }
48
49
    /**
50
     * @param        $script
51
     * @param string $location
52
     * @param bool   $async
53
     * @param null   $name
54
     * @param string $context
55
     */
56
    public function addScript($script, $location = 'head', $async = false, $name = null, $context = AssetsHelper::CONTEXT_APP)
57
    {
58
        $this->assetsHelper->setContext($context)
59
            ->addScript($script, $location, $async, $name)
60
            ->setContext(AssetsHelper::CONTEXT_APP);
61
62
        return $this;
63
    }
64
65
    /**
66
     * @param        $script
67
     * @param string $location
68
     * @param string $context
69
     */
70
    public function addScriptDeclaration($script, $location = 'head', $context = AssetsHelper::CONTEXT_APP)
71
    {
72
        $this->assetsHelper->setContext($context)
73
            ->addScriptDeclaration($script, $location, $context)
0 ignored issues
show
The call to Mautic\CoreBundle\Templa...:addScriptDeclaration() has too many arguments starting with $context. ( Ignorable by Annotation )

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

73
            ->/** @scrutinizer ignore-call */ addScriptDeclaration($script, $location, $context)

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
74
            ->setContext(AssetsHelper::CONTEXT_APP);
75
76
        return $this;
77
    }
78
79
    /**
80
     * @param        $stylesheet
81
     * @param string $context
82
     */
83
    public function addStylesheet($stylesheet, $context = AssetsHelper::CONTEXT_APP)
84
    {
85
        $this->assetsHelper->setContext($context)
86
            ->addStylesheet($stylesheet)
87
            ->setContext(AssetsHelper::CONTEXT_APP);
88
89
        return $this;
90
    }
91
92
    /**
93
     * @param        $styles
94
     * @param string $context
95
     */
96
    public function addStyleDeclaration($styles, $context = AssetsHelper::CONTEXT_APP)
97
    {
98
        $this->assetsHelper->setContext($context)
99
            ->addStyleDeclaration($styles)
100
            ->setContext(AssetsHelper::CONTEXT_APP);
101
102
        return $this;
103
    }
104
}
105