Passed
Push — master ( 77f10d...b1f89f )
by Michael
03:06
created

MenusPlugin::subMenus()   A

Complexity

Conditions 5
Paths 3

Size

Total Lines 20
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 13
nc 3
nop 0
dl 0
loc 20
rs 9.5222
c 0
b 0
f 0
1
<?php
2
3
namespace XoopsModules\Xoositemap\Plugin;
4
5
/**
6
 * Xoopartners module
7
 *
8
 * You may not change or alter any portion of this comment or credits
9
 * of supporting developers from this source code or any supporting source code
10
 * which is considered copyrighted (c) material of the original comment or credit authors.
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
 *
15
 * @copyright       The XOOPS Project http://sourceforge.net/projects/xoops/
16
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
17
 * @package         Xoopartners
18
 * @since           2.6.0
19
 * @author          Laurent JEN (Aka DuGris)
20
 * @version         $Id$
21
 */
22
class MenusPlugin extends \Xoops\Module\Plugin\PluginAbstract implements \MenusPluginInterface
0 ignored issues
show
Bug introduced by
The type Xoops\Module\Plugin\PluginAbstract was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
Bug introduced by
The type MenusPluginInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
23
{
24
    /**
25
     * expects an array of array containing:
26
     * name,      Name of the submenu
27
     * url,       Url of the submenu relative to the module
28
     * ex: return array(0 => array(
29
     *      'name' => _MI_PUBLISHER_SUB_SMNAME3;
30
     *      'url' => "search.php";
31
     *    ));
32
     *
33
     * @return array
34
     */
35
    public function subMenus()
36
    {
37
        $ret = [];
38
        if (\Xoops::getInstance()->isModule() && 'xoositemap' == \Xoops::getInstance()->module->getVar('dirname')) {
39
            $xoops = \Xoops::getInstance();
40
            $helper = \XoopsModules\Xoositemap\Helper::getInstance();
41
            $sitemapConfig = $helper->loadConfig();
42
43
            $i = 0;
44
            if ($sitemapConfig['xoositemap_main']) {
45
                foreach ($sitemapConfig['xoositemapModule'] as $k => $module) {
46
                    $menu = $xoops->module->getByDirname($module);
47
                    $ret[$i]['name'] = $menu->getVar('name');
48
                    $ret[$i]['url'] = 'index.php?op=' . $module;
49
                    ++$i;
50
                }
51
            }
52
        }
53
54
        return $ret;
55
    }
56
}
57