Passed
Push — master ( 335c59...1f66c0 )
by Julito
07:27
created

PluginsController::getSettingsManager()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
namespace Chamilo\CoreBundle\Controller\Admin;
6
7
use Chamilo\SettingsBundle\Manager\SettingsManager;
8
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
9
use Sylius\Bundle\SettingsBundle\Controller\SettingsController as SyliusSettingsController;
10
use Symfony\Component\Routing\Annotation\Route;
11
12
/**
13
 * Class SettingsController.
14
 */
15
class PluginsController extends SyliusSettingsController
16
{
17
    /**
18
     * @Security("has_role('ROLE_ADMIN')")
19
     *
20
     * @Route("/plugins")
21
     *
22
     * @return array
23
     */
24
    public function pluginsAction()
25
    {
26
        $appPlugin = new \AppPlugin();
27
        $installedPlugins = $appPlugin->getInstalledPlugins();
28
29
        return $this->render(
30
            '@ChamiloTheme/Admin/Settings/plugins.html.twig',
31
            [
32
                'plugins' => $installedPlugins,
33
            ]
34
        );
35
    }
36
37
    /**
38
     * @Security("has_role('ROLE_ADMIN')")
39
     *
40
     * @Route("/plugins/add")
41
     *
42
     * @return array
43
     */
44
    public function pluginsAddAction()
45
    {
46
        $appPlugin = new \AppPlugin();
47
        $allPlugins = $appPlugin->read_plugins_from_path();
48
        $allPluginsList = [];
49
        foreach ($allPlugins as $pluginName) {
50
            $file = api_get_path(SYS_PLUGIN_PATH).$pluginName.'/plugin.php';
51
52
            if (is_file($file)) {
53
                $pluginInfo = require $file;
54
                var_dump($pluginInfo);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($pluginInfo) looks like debug code. Are you sure you do not want to remove it?
Loading history...
55
                exit;
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
56
                $allPluginsList[] = $pluginInfo;
0 ignored issues
show
Unused Code introduced by
$allPluginsList[] = $pluginInfo is not reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
57
            }
58
        }
59
60
        $installedPlugins = $appPlugin->getInstalledPlugins();
61
62
        return $this->render(
63
            '@ChamiloTheme/Admin/Settings/pluginsAdd.html.twig',
64
            [
65
                'plugins' => $allPluginsList,
66
                'installed_plugins' => $installedPlugins,
67
            ]
68
        );
69
    }
70
}
71