Issues (3627)

Templating/Helper/SidebarCanvasHelper.php (1 issue)

1
<?php
2
3
/*
4
 * @copyright   2014 Mautic Contributors. All rights reserved
5
 * @author      Mautic
6
 *
7
 * @link        http://mautic.org
8
 *
9
 * @license     GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
10
 */
11
12
namespace Mautic\CoreBundle\Templating\Helper;
13
14
use Mautic\CoreBundle\CoreEvents;
15
use Mautic\CoreBundle\Event\SidebarCanvasEvent;
16
use Symfony\Bundle\FrameworkBundle\Templating\PhpEngine;
17
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
18
use Symfony\Component\Templating\Helper\Helper;
19
20
/**
21
 * Class SidebarCanvasHelper.
22
 */
23
class SidebarCanvasHelper extends Helper
24
{
25
    /**
26
     * @var array
27
     */
28
    protected $canvases = ['left', 'main', 'right'];
29
30
    /**
31
     * @var array
32
     */
33
    protected $content = [];
34
35
    /**
36
     * @var EventDispatcherInterface
37
     */
38
    protected $dispatcher;
39
40
    /**
41
     * SidebarCanvasHelper constructor.
42
     */
43
    public function __construct(EventDispatcherInterface $dispatcher)
44
    {
45
        $this->dispatcher = $dispatcher;
46
    }
47
48
    public function renderCanvasContent(PhpEngine $templating)
49
    {
50
        if ($this->dispatcher->hasListeners(CoreEvents::BUILD_CANVAS_CONTENT)) {
51
            $event = new SidebarCanvasEvent($templating);
52
            $this->dispatcher->dispatch(CoreEvents::BUILD_CANVAS_CONTENT, $event);
53
            $this->content = $event->getCanvasContent();
54
        }
55
56
        $adminMenuContent = $templating['menu']->render('admin');
0 ignored issues
show
The method render() does not exist on Symfony\Component\Templa...\Helper\HelperInterface. It seems like you code against a sub-type of Symfony\Component\Templa...\Helper\HelperInterface such as Symfony\Bundle\Framework...\Helper\StopwatchHelper or Symfony\Bundle\Framework...ng\Helper\ActionsHelper or Knp\Bundle\MenuBundle\Templating\Helper\MenuHelper or Mautic\CoreBundle\Templating\Helper\MenuHelper. ( Ignorable by Annotation )

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

56
        /** @scrutinizer ignore-call */ 
57
        $adminMenuContent = $templating['menu']->render('admin');
Loading history...
57
58
        if (!empty($adminMenuContent)) {
59
            $settingsMenu = [
60
                'header'  => 'mautic.core.settings',
61
                'content' => '<nav class="nav-sidebar">'.$adminMenuContent.'</nav>',
62
                'footer'  => '',
63
            ];
64
65
            if (empty($this->content['main'])) {
66
                //insert settings menu
67
                $this->content['main'] = $settingsMenu;
68
            } else {
69
                $this->content['left'] = $settingsMenu;
70
            }
71
        }
72
73
        $hasContent = false;
74
        foreach ($this->canvases as $canvas) {
75
            if (!isset($this->content[$canvas])) {
76
                $this->content[$canvas] = false;
77
            }
78
79
            if ($this->content[$canvas]) {
80
                $hasContent = true;
81
            }
82
        }
83
84
        if (!$hasContent) {
85
            $this->content['main'] = [
86
                'header'  => false,
87
                'content' => '<div class="mautibot-image"><img class="img-responsive mt-lg" style="margin-right: auto; margin-left: auto;" src="'.MautibotHelper::get('wave').'" /></div>',
88
                'footer'  => '',
89
            ];
90
        }
91
    }
92
93
    /**
94
     * @return mixed
95
     */
96
    public function getLeftContent()
97
    {
98
        return $this->content['left'];
99
    }
100
101
    /**
102
     * @return mixed
103
     */
104
    public function getRightContent()
105
    {
106
        return $this->content['right'];
107
    }
108
109
    /**
110
     * @return mixed
111
     */
112
    public function getMainContent()
113
    {
114
        return $this->content['main'];
115
    }
116
117
    /**
118
     * @return array
119
     */
120
    public function getContent()
121
    {
122
        return $this->content;
123
    }
124
125
    /**
126
     * {@inheritdoc}
127
     */
128
    public function getName()
129
    {
130
        return 'canvas';
131
    }
132
}
133