Completed
Push — master ( 562606...354044 )
by Julito
09:19
created

AppPlugin::getPluginRegions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
/* See license terms in /license.txt */
3
4
use ChamiloSession as Session;
5
6
/**
7
 * Class AppPlugin.
8
 */
9
class AppPlugin
10
{
11
    public $plugin_regions = [
12
        'main_top',
13
        'main_bottom',
14
        'login_top',
15
        'login_bottom',
16
        'menu_top',
17
        'menu_bottom',
18
        'content_top',
19
        'content_bottom',
20
        'header_main',
21
        'header_center',
22
        'header_left',
23
        'header_right',
24
        'pre_footer',
25
        'footer_left',
26
        'footer_center',
27
        'footer_right',
28
        'menu_administrator',
29
        'course_tool_plugin',
30
    ];
31
32
    public $installedPluginListName = [];
33
    public $installedPluginListObject = [];
34
    private static $instance;
35
36
    /**
37
     * Constructor.
38
     */
39
    public function __construct()
40
    {
41
    }
42
43
    /**
44
     * @return AppPlugin
45
     */
46
    public static function getInstance()
47
    {
48
        if (!isset(self::$instance)) {
49
            self::$instance = new self();
50
        }
51
52
        return self::$instance;
53
    }
54
55
    /**
56
     * Read plugin from path.
57
     *
58
     * @return array
59
     */
60
    public function read_plugins_from_path()
61
    {
62
        /* We scan the plugin directory. Each folder is a potential plugin. */
63
        $pluginPath = api_get_path(SYS_PLUGIN_PATH);
64
        $plugins = [];
65
        $handle = @opendir($pluginPath);
66
        while (false !== ($file = readdir($handle))) {
0 ignored issues
show
Bug introduced by
It seems like $handle can also be of type false; however, parameter $dir_handle of readdir() does only seem to accept resource, 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

66
        while (false !== ($file = readdir(/** @scrutinizer ignore-type */ $handle))) {
Loading history...
67
            if ($file != '.' && $file != '..' && is_dir(api_get_path(SYS_PLUGIN_PATH).$file)) {
68
                $plugins[] = $file;
69
            }
70
        }
71
        @closedir($handle);
0 ignored issues
show
Bug introduced by
Are you sure the usage of closedir($handle) is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Bug introduced by
It seems like $handle can also be of type false; however, parameter $dir_handle of closedir() does only seem to accept resource, 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

71
        @closedir(/** @scrutinizer ignore-type */ $handle);
Loading history...
Security Best Practice introduced by
It seems like you do not handle an error condition for closedir(). This can introduce security issues, and is generally not recommended. ( Ignorable by Annotation )

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

71
        /** @scrutinizer ignore-unhandled */ @closedir($handle);

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
72
        sort($plugins);
73
74
        return $plugins;
75
    }
76
77
    /**
78
     * @return array
79
     */
80
    public function getInstalledPluginListName()
81
    {
82
        if (empty($this->installedPluginListName)) {
83
            $this->installedPluginListName = $this->getInstalledPlugins();
84
        }
85
86
        return $this->installedPluginListName;
87
    }
88
89
    /**
90
     * @return array List of Plugin
91
     */
92
    public function getInstalledPluginListObject()
93
    {
94
        if (empty($this->installedPluginListObject)) {
95
            $this->setInstalledPluginListObject();
96
        }
97
98
        return $this->installedPluginListObject;
99
    }
100
101
    public function setInstalledPluginListObject()
102
    {
103
        $pluginListName = $this->getInstalledPluginListName();
104
        $pluginList = [];
105
        if (!empty($pluginListName)) {
106
            foreach ($pluginListName as $pluginName) {
107
                $pluginInfo = $this->getPluginInfo($pluginName, true);
108
                if (isset($pluginInfo['plugin_class'])) {
109
                    $pluginList[] = $pluginInfo['plugin_class']::create();
110
                }
111
            }
112
        }
113
        $this->installedPluginListObject = $pluginList;
114
    }
115
116
    /**
117
     * @param string $plugin
118
     *
119
     * @return bool
120
     */
121
    public function isInstalled($plugin)
122
    {
123
        $list = self::getInstalledPlugins(false);
0 ignored issues
show
Bug Best Practice introduced by
The method AppPlugin::getInstalledPlugins() is not static, but was called statically. ( Ignorable by Annotation )

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

123
        /** @scrutinizer ignore-call */ 
124
        $list = self::getInstalledPlugins(false);
Loading history...
124
125
        return in_array($plugin, $list);
126
    }
127
128
    /**
129
     * @param bool $fromDatabase
130
     *
131
     * @return array
132
     */
133
    public function getInstalledPlugins($fromDatabase = true)
134
    {
135
        static $installedPlugins = null;
136
137
        if ($fromDatabase === false) {
138
            if (is_array($installedPlugins)) {
139
                return $installedPlugins;
140
            }
141
        }
142
143
        if ($fromDatabase || $installedPlugins === null) {
144
            $installedPlugins = [];
145
            $plugins = api_get_settings_params(
146
                [
147
                    'variable = ? AND selected_value = ? AND category = ? ' => ['status', 'installed', 'Plugins'],
148
                ]
149
            );
150
151
            if (!empty($plugins)) {
152
                foreach ($plugins as $row) {
153
                    $installedPlugins[$row['subkey']] = true;
154
                }
155
                $installedPlugins = array_keys($installedPlugins);
156
            }
157
        }
158
159
        return $installedPlugins;
160
    }
161
162
    /**
163
     * @param string $pluginName
164
     * @param int    $urlId
165
     */
166
    public function install($pluginName, $urlId = null)
167
    {
168
        $urlId = (int) $urlId;
169
        if (empty($urlId)) {
170
            $urlId = api_get_current_access_url_id();
171
        }
172
173
        api_add_setting(
174
            'installed',
175
            'status',
176
            $pluginName,
177
            'setting',
178
            'Plugins',
179
            $pluginName,
180
            '',
181
            '',
182
            '',
183
            $urlId,
184
            1
185
        );
186
187
        $pluginPath = api_get_path(SYS_PLUGIN_PATH).$pluginName.'/install.php';
188
189
        if (is_file($pluginPath) && is_readable($pluginPath)) {
190
            // Execute the install procedure.
191
192
            require $pluginPath;
193
        }
194
    }
195
196
    /**
197
     * @param string $pluginName
198
     * @param int    $urlId
199
     */
200
    public function uninstall($pluginName, $urlId = null)
201
    {
202
        $urlId = (int) $urlId;
203
        if (empty($urlId)) {
204
            $urlId = api_get_current_access_url_id();
205
        }
206
207
        // First call the custom uninstall to allow full access to global settings
208
        $pluginPath = api_get_path(SYS_PLUGIN_PATH).$pluginName.'/uninstall.php';
209
        if (is_file($pluginPath) && is_readable($pluginPath)) {
210
            // Execute the uninstall procedure.
211
212
            require $pluginPath;
213
        }
214
215
        // Second remove all remaining global settings
216
        api_delete_settings_params(
217
            ['category = ? AND access_url = ? AND subkey = ? ' => ['Plugins', $urlId, $pluginName]]
218
        );
219
    }
220
221
    /**
222
     * @param string $pluginName
223
     *
224
     * @return array
225
     */
226
    public function get_areas_by_plugin($pluginName)
227
    {
228
        $result = api_get_settings('Plugins');
229
        $areas = [];
230
        foreach ($result as $row) {
231
            if ($pluginName == $row['selected_value']) {
232
                $areas[] = $row['variable'];
233
            }
234
        }
235
236
        return $areas;
237
    }
238
239
    /**
240
     * @param string $pluginName
241
     *
242
     * @return bool
243
     */
244
    public function is_valid_plugin($pluginName)
245
    {
246
        if (is_dir(api_get_path(SYS_PLUGIN_PATH).$pluginName)) {
247
            if (is_file(api_get_path(SYS_PLUGIN_PATH).$pluginName.'/index.php')) {
248
                return true;
249
            }
250
        }
251
252
        return false;
253
    }
254
255
    /**
256
     * @return array
257
     */
258
    public function getPluginRegions()
259
    {
260
        sort($this->plugin_regions);
261
262
        return $this->plugin_regions;
263
    }
264
265
    /**
266
     * @param array            $pluginRegionList
267
     * @param string           $region
268
     * @param Twig_Environment $template
269
     * @param bool             $forced
270
     *
271
     * @return string|null
272
     */
273
    public function loadRegion($pluginName, $region, $template, $forced = false)
274
    {
275
        if ($region == 'course_tool_plugin') {
276
            return '';
277
        }
278
279
        ob_start();
280
        $this->getAllPluginContentsByRegion($pluginName, $region, $template, $forced);
281
        $content = ob_get_contents();
282
        ob_end_clean();
283
284
        return $content;
285
    }
286
287
    /**
288
     * Loads the translation files inside a plugin if exists.
289
     * It loads by default english see the hello world plugin.
290
     *
291
     * @param string $plugin_name
292
     *
293
     * @todo add caching
294
     */
295
    public function load_plugin_lang_variables($plugin_name)
296
    {
297
        $language_interface = api_get_interface_language();
298
        $root = api_get_path(SYS_PLUGIN_PATH);
299
        $strings = null;
300
301
        // 1. Loading english if exists
302
        $english_path = $root.$plugin_name.'/lang/english.php';
303
        if (is_readable($english_path)) {
304
            include $english_path;
305
306
            foreach ($strings as $key => $string) {
0 ignored issues
show
Bug introduced by
The expression $strings of type null is not traversable.
Loading history...
307
                $GLOBALS[$key] = $string;
308
            }
309
        }
310
311
        // 2. Loading the system language
312
        if ($language_interface != 'english') {
313
            $path = $root.$plugin_name."/lang/$language_interface.php";
314
            if (is_readable($path)) {
315
                include $path;
316
                if (!empty($strings)) {
317
                    foreach ($strings as $key => $string) {
318
                        $GLOBALS[$key] = $string;
319
                    }
320
                }
321
            } else {
322
                /*$interfaceLanguageId = api_get_language_id($language_interface);
323
                $interfaceLanguageInfo = api_get_language_info($interfaceLanguageId);
324
                $languageParentId = intval($interfaceLanguageInfo['parent_id']);
325
326
                if ($languageParentId > 0) {
327
                    $languageParentInfo = api_get_language_info($languageParentId);
328
                    $languageParentFolder = $languageParentInfo['dokeos_folder'];
329
330
                    $parentPath = "{$root}{$plugin_name}/lang/{$languageParentFolder}.php";
331
                    if (is_readable($parentPath)) {
332
                        include $parentPath;
333
                        if (!empty($strings)) {
334
                            foreach ($strings as $key => $string) {
335
                                $this->strings[$key] = $string;
336
                            }
337
                        }
338
                    }
339
                }*/
340
            }
341
        }
342
    }
343
344
    /**
345
     * @param array            $_plugins
346
     * @param string           $region
347
     * @param Twig_Environment $template
348
     * @param bool             $forced
349
     *
350
     * @return bool
351
     *
352
     * @todo improve this function
353
     */
354
    public function getAllPluginContentsByRegion($plugin_name, $region, $template, $forced = false)
355
    {
356
        // The plugin_info variable is available inside the plugin index
357
        $plugin_info = $this->getPluginInfo($plugin_name, $forced);
358
359
        // We also know where the plugin is
360
        $plugin_info['current_region'] = $region;
361
362
        // Loading the plugin/XXX/index.php file
363
        $plugin_file = api_get_path(SYS_PLUGIN_PATH)."$plugin_name/index.php";
364
365
        if (file_exists($plugin_file)) {
366
            //Loading the lang variables of the plugin if exists
367
            self::load_plugin_lang_variables($plugin_name);
0 ignored issues
show
Bug Best Practice introduced by
The method AppPlugin::load_plugin_lang_variables() is not static, but was called statically. ( Ignorable by Annotation )

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

367
            self::/** @scrutinizer ignore-call */ 
368
                  load_plugin_lang_variables($plugin_name);
Loading history...
368
369
            // Printing the plugin index.php file
370
            require $plugin_file;
371
372
            // If the variable $_template is set we assign those values to be accessible in Twig
373
            if (isset($_template)) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $_template seems to never exist and therefore isset should always be false.
Loading history...
374
                $_template['plugin_info'] = $plugin_info;
375
            } else {
376
                $_template = [];
377
                $_template['plugin_info'] = $plugin_info;
378
            }
379
380
            // Setting the plugin info available in the template if exists.
381
            //$template->addGlobal($plugin_name, $_template);
382
383
            // Loading the Twig template plugin files if exists
384
            $templateList = [];
385
            if (isset($plugin_info) && isset($plugin_info['templates'])) {
386
                $templateList = $plugin_info['templates'];
387
            }
388
389
            if (!empty($templateList)) {
390
                foreach ($templateList as $pluginTemplate) {
391
                    if (!empty($pluginTemplate)) {
392
                        $templatePluginFile = "$plugin_name/$pluginTemplate"; // for twig
393
                        //$template->render($templatePluginFile, []);
394
                    }
395
                }
396
            }
397
        }
398
399
        return true;
400
    }
401
402
    /**
403
     * Loads plugin info.
404
     *
405
     * @staticvar array $plugin_data
406
     *
407
     * @param string $pluginName
408
     * @param bool   $forced     load from DB or from the static array
409
     *
410
     * @return array
411
     *
412
     * @todo filter setting_form
413
     */
414
    public function getPluginInfo($pluginName, $forced = false)
415
    {
416
        //$pluginData = Session::read('plugin_data');
417
        if (0) {
418
            //if (isset($pluginData[$pluginName]) && $forced == false) {
419
            return $pluginData[$pluginName];
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $pluginData seems to be never defined.
Loading history...
420
        } else {
421
            $plugin_file = api_get_path(SYS_PLUGIN_PATH)."$pluginName/plugin.php";
422
423
            $plugin_info = [];
424
            if (file_exists($plugin_file)) {
425
                require $plugin_file;
426
            }
427
428
            // @todo check if settings are already added
429
            // Extra options
430
            $plugin_settings = api_get_settings_params(
431
                [
432
                    'subkey = ? AND category = ? AND type = ? AND access_url = ?' => [
433
                        $pluginName,
434
                        'Plugins',
435
                        'setting',
436
                        api_get_current_access_url_id(),
437
                    ],
438
                ]
439
            );
440
441
            $settings_filtered = [];
442
            foreach ($plugin_settings as $item) {
443
                if (!empty($item['selected_value'])) {
444
                    //if (unserialize($item['selected_value']) !== false) {
445
                        //$item['selected_value'] = unserialize($item['selected_value']);
446
                    //}
447
                }
448
                $settings_filtered[$item['variable']] = $item['selected_value'];
449
            }
450
451
            $plugin_info['settings'] = $settings_filtered;
452
            $pluginData[$pluginName] = $plugin_info;
0 ignored issues
show
Comprehensibility Best Practice introduced by
$pluginData was never initialized. Although not strictly required by PHP, it is generally a good practice to add $pluginData = array(); before regardless.
Loading history...
453
            //Session::write('plugin_data', $pluginData);
454
455
            return $plugin_info;
456
        }
457
    }
458
459
    /**
460
     * Get the template list.
461
     *
462
     * @param string $pluginName
463
     *
464
     * @return bool
465
     */
466
    public function get_templates_list($pluginName)
467
    {
468
        $plugin_info = $this->getPluginInfo($pluginName);
469
        if (isset($plugin_info) && isset($plugin_info['templates'])) {
470
            return $plugin_info['templates'];
471
        }
472
473
        return false;
474
    }
475
476
    /**
477
     * Remove all regions of an specific plugin.
478
     *
479
     * @param string $plugin
480
     */
481
    public function removeAllRegions($plugin)
482
    {
483
        if (!empty($plugin)) {
484
            api_delete_settings_params(
485
                [
486
                    'category = ? AND type = ? AND access_url = ? AND subkey = ? ' => [
487
                        'Plugins',
488
                        'region',
489
                        api_get_current_access_url_id(),
490
                        $plugin,
491
                    ],
492
                ]
493
            );
494
        }
495
    }
496
497
    /**
498
     * Add a plugin to a region.
499
     *
500
     * @param string $plugin
501
     * @param string $region
502
     */
503
    public function add_to_region($plugin, $region)
504
    {
505
        api_add_setting(
506
            $plugin,
507
            $region,
508
            $plugin,
509
            'region',
510
            'Plugins',
511
            $plugin,
512
            '',
513
            '',
514
            '',
515
            api_get_current_access_url_id(),
516
            1
517
        );
518
    }
519
520
    /**
521
     * @param int $courseId
522
     */
523
    public function install_course_plugins($courseId)
524
    {
525
        $pluginList = $this->getInstalledPluginListObject();
526
527
        if (!empty($pluginList)) {
528
            /** @var Plugin $obj */
529
            foreach ($pluginList as $obj) {
530
                $pluginName = $obj->get_name();
531
                $plugin_path = api_get_path(SYS_PLUGIN_PATH).$pluginName.'/plugin.php';
532
533
                if (file_exists($plugin_path)) {
534
                    require $plugin_path;
535
                    if (isset($plugin_info) && isset($plugin_info['plugin_class']) && $obj->isCoursePlugin) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $plugin_info does not exist. Did you maybe mean $plugin_path?
Loading history...
536
                        $obj->course_install($courseId);
537
                    }
538
                }
539
            }
540
        }
541
    }
542
543
    /**
544
     * Trigger for Plugin::doWhenDeleting[Item] functions.
545
     *
546
     * @param string $itemType
547
     * @param int    $itemId
548
     */
549
    public function performActionsWhenDeletingItem($itemType, $itemId)
550
    {
551
        $pluginList = $this->getInstalledPluginListObject();
552
553
        if (empty($pluginList)) {
554
            return;
555
        }
556
557
        /** @var Plugin $pluginObj */
558
        foreach ($pluginList as $pluginObj) {
559
            switch ($itemType) {
560
                case 'course':
561
                    $pluginObj->doWhenDeletingCourse($itemId);
562
                    break;
563
                case 'session':
564
                    $pluginObj->doWhenDeletingSession($itemId);
565
                    break;
566
                case 'user':
567
                    $pluginObj->doWhenDeletingUser($itemId);
568
                    break;
569
            }
570
        }
571
    }
572
573
    /**
574
     * Add the course settings to the course settings form.
575
     *
576
     * @param FormValidator $form
577
     */
578
    public function add_course_settings_form($form)
579
    {
580
        $pluginList = $this->getInstalledPluginListObject();
581
        /** @var Plugin $obj */
582
        foreach ($pluginList as $obj) {
583
            $pluginName = $obj->get_name();
584
            $pluginTitle = $obj->get_title();
585
            if (!empty($obj->course_settings)) {
586
                if (is_file(api_get_path(SYS_CODE_PATH).'img/icons/'.ICON_SIZE_SMALL.'/'.$pluginName.'.png')) {
587
                    $icon = Display::return_icon(
588
                        $pluginName.'.png',
589
                        Security::remove_XSS($pluginTitle),
590
                        '',
591
                        ICON_SIZE_SMALL
592
                    );
593
                } else {
594
                    $icon = Display::return_icon(
595
                        'plugins.png',
596
                        Security::remove_XSS($pluginTitle),
597
                        '',
598
                        ICON_SIZE_SMALL
599
                    );
600
                }
601
602
                $form->addHtml('<div class="panel panel-default">');
603
                $form->addHtml('
604
                    <div class="panel-heading" role="tab" id="heading-'.$pluginName.'-settings">
605
                        <h4 class="panel-title">
606
                            <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-'.$pluginName.'-settings" aria-expanded="false" aria-controls="collapse-'.$pluginName.'-settings">
607
                ');
608
                $form->addHtml($icon.' '.$pluginTitle);
609
                $form->addHtml('
610
                            </a>
611
                        </h4>
612
                    </div>
613
                ');
614
                $form->addHtml('
615
                    <div id="collapse-'.$pluginName.'-settings" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-'.$pluginName.'-settings">
616
                        <div class="panel-body">
617
                ');
618
619
                $groups = [];
620
                foreach ($obj->course_settings as $setting) {
621
                    if ($obj->validateCourseSetting($setting['name']) === false) {
622
                        continue;
623
                    }
624
                    if ($setting['type'] != 'checkbox') {
625
                        $form->addElement($setting['type'], $setting['name'], $obj->get_lang($setting['name']));
626
                    } else {
627
                        $element = &$form->createElement(
628
                            $setting['type'],
629
                            $setting['name'],
630
                            '',
631
                            $obj->get_lang($setting['name'])
632
                        );
633
                        if (isset($setting['init_value']) && $setting['init_value'] == 1) {
634
                            $element->setChecked(true);
635
                        }
636
                        $form->addElement($element);
637
638
                        if (isset($setting['group'])) {
639
                            $groups[$setting['group']][] = $element;
640
                        }
641
                    }
642
                }
643
                foreach ($groups as $k => $v) {
644
                    $form->addGroup($groups[$k], $k, [$obj->get_lang($k)]);
645
                }
646
                $form->addButtonSave(get_lang('SaveSettings'));
647
                $form->addHtml('
648
                        </div>
649
                    </div>
650
                ');
651
                $form->addHtml('</div>');
652
            }
653
        }
654
    }
655
656
    /**
657
     * Get all course settings from all installed plugins.
658
     *
659
     * @return array
660
     */
661
    public function getAllPluginCourseSettings()
662
    {
663
        $pluginList = $this->getInstalledPluginListObject();
664
        /** @var Plugin $obj */
665
        $courseSettings = [];
666
        if (!empty($pluginList)) {
667
            foreach ($pluginList as $obj) {
668
                $pluginCourseSetting = $obj->getCourseSettings();
669
                $courseSettings = array_merge($courseSettings, $pluginCourseSetting);
670
            }
671
        }
672
673
        return $courseSettings;
674
    }
675
676
    /**
677
     * When saving the plugin values in the course settings, check whether
678
     * a callback method should be called and send it the updated settings.
679
     *
680
     * @param array $values The new settings the user just saved
681
     */
682
    public function saveCourseSettingsHook($values)
683
    {
684
        $pluginList = $this->getInstalledPluginListObject();
685
686
        /** @var Plugin $obj */
687
        foreach ($pluginList as $obj) {
688
            $settings = $obj->getCourseSettings();
689
            $subValues = [];
690
            if (!empty($settings)) {
691
                foreach ($settings as $v) {
692
                    if (isset($values[$v])) {
693
                        $subValues[$v] = $values[$v];
694
                    }
695
                }
696
            }
697
698
            if (!empty($subValues)) {
699
                $obj->course_settings_updated($subValues);
700
            }
701
        }
702
    }
703
704
    /**
705
     * Get first SMS plugin name.
706
     *
707
     * @return string|bool
708
     */
709
    public function getSMSPluginName()
710
    {
711
        $installedPluginsList = $this->getInstalledPluginListObject();
712
        foreach ($installedPluginsList as $installedPlugin) {
713
            if ($installedPlugin->isMailPlugin) {
714
                return get_class($installedPlugin);
715
            }
716
        }
717
718
        return false;
719
    }
720
721
    /**
722
     * @return SmsPluginLibraryInterface
723
     */
724
    public function getSMSPluginLibrary()
725
    {
726
        $className = $this->getSMSPluginName();
727
        $className = str_replace('Plugin', '', $className);
728
729
        if (class_exists($className)) {
730
            return new $className();
731
        }
732
733
        return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type SmsPluginLibraryInterface.
Loading history...
734
    }
735
736
    /**
737
     * @param array            $pluginRegionList
738
     * @param string           $pluginRegion
739
     * @param Twig_Environment $twig
740
     */
741
    public function setPluginRegion($pluginRegionList, $pluginRegion, $twig)
742
    {
743
        $regionContent = $this->loadRegion(
744
            $pluginRegionList,
745
            $pluginRegion,
746
            $twig,
747
            true //$this->force_plugin_load
748
        );
749
750
        //$twig->addGlobal('plugin_'.$pluginRegion, $regionContent);
751
    }
752
}
753