Passed
Push — master ( 3264d9...ab77f1 )
by Julito
06:54
created

PluginsController::index()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
namespace Chamilo\CoreBundle\Controller\Admin;
8
9
use AppPlugin;
10
use Chamilo\CoreBundle\Controller\BaseController;
11
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
12
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
13
use Symfony\Component\HttpFoundation\Response;
14
use Symfony\Component\Routing\Annotation\Route;
15
16
#[Route('/plugins')]
17
class PluginsController extends BaseController
18
{
19
    #[IsGranted('ROLE_ADMIN')]
20
    #[Route('/', name: 'chamilo_core_plugins', methods:['GET', 'POST'])]
21
    public function index(): Response
22
    {
23
        $appPlugin = new AppPlugin();
24
        $installedPlugins = $appPlugin->getInstalledPlugins();
25
26
        return $this->render(
27
            '@ChamiloCore/Admin/Settings/plugins.html.twig',
28
            [
29
                'plugins' => $installedPlugins,
30
            ]
31
        );
32
    }
33
34
    /**
35
     * @Security("is_granted('ROLE_ADMIN')")
36
     *
37
     * @Route("/add")
38
     */
39
    public function pluginsAddAction(): Response
40
    {
41
        $appPlugin = new AppPlugin();
42
        $allPlugins = $appPlugin->read_plugins_from_path();
43
        $allPluginsList = [];
44
        foreach ($allPlugins as $pluginName) {
45
            /*$file = api_get_path(SYS_PLUGIN_PATH).$pluginName.'/plugin.php';
46
47
            if (is_file($file)) {
48
                $pluginInfo = require $file;
49
                var_dump($pluginInfo);exit;
50
                $allPluginsList[] = $pluginInfo;
51
            }*/
52
        }
53
54
        $installedPlugins = $appPlugin->getInstalledPlugins();
55
56
        return $this->render(
57
            '@ChamiloCore/Admin/Settings/pluginsAdd.html.twig',
58
            [
59
                'plugins' => $allPluginsList,
60
                'installed_plugins' => $installedPlugins,
61
            ]
62
        );
63
    }
64
}
65