6
6
7
7
namespace Chamilo \CoreBundle \Controller \Admin ;
8
8
9
+ use AppPlugin ;
9
10
use Chamilo \CoreBundle \Controller \BaseController ;
10
11
use Chamilo \CoreBundle \Entity \Page ;
11
12
use Chamilo \CoreBundle \Entity \PageCategory ;
12
13
use Chamilo \CoreBundle \Entity \SequenceResource ;
13
14
use Chamilo \CoreBundle \Event \AbstractEvent ;
14
15
use Chamilo \CoreBundle \Event \AdminBlockDisplayedEvent ;
15
16
use Chamilo \CoreBundle \Event \Events ;
17
+ use Chamilo \CoreBundle \Helpers \AccessUrlHelper ;
16
18
use Chamilo \CoreBundle \Repository \PageCategoryRepository ;
17
19
use Chamilo \CoreBundle \Repository \PageRepository ;
20
+ use Chamilo \CoreBundle \Repository \PluginRepository ;
18
21
use Chamilo \CoreBundle \Settings \SettingsManager ;
22
+ use Plugin ;
19
23
use Sensio \Bundle \FrameworkExtraBundle \Configuration \Security ;
20
24
use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
21
25
use Symfony \Component \HttpFoundation \JsonResponse ;
@@ -38,6 +42,8 @@ public function __construct(
38
42
private readonly PageCategoryRepository $ pageCategoryRepository ,
39
43
private readonly SerializerInterface $ serializer ,
40
44
private readonly EventDispatcherInterface $ eventDispatcher ,
45
+ private readonly PluginRepository $ pluginRepository ,
46
+ private readonly AccessUrlHelper $ accessUrlHelper ,
41
47
) {
42
48
$ this ->extAuthSource = [
43
49
'extldap ' => [],
@@ -134,6 +140,12 @@ public function __invoke(): JsonResponse
134
140
'items ' => $ this ->getItemsChamilo (),
135
141
'extraContent ' => $ this ->getExtraContent ('block-admin-chamilo ' ),
136
142
];
143
+
144
+ $ json ['plugins ' ] = [
145
+ 'id ' => 'block-admin-plugins ' ,
146
+ 'editable ' => false ,
147
+ 'items ' => $ this ->getItemsPlugins (),
148
+ ];
137
149
}
138
150
139
151
/* Sessions */
@@ -861,4 +873,33 @@ private function getItemsSessions(): array
861
873
862
874
return $ items ;
863
875
}
876
+
877
+ private function getItemsPlugins (): array
878
+ {
879
+ $ items = [];
880
+
881
+ $ accessUrl = $ this ->accessUrlHelper ->getCurrent ();
882
+ $ appPlugin = new AppPlugin ();
883
+ $ plugins = $ this ->pluginRepository ->getInstalledPlugins ();
884
+
885
+ foreach ($ plugins as $ plugin ) {
886
+ $ pluginInfo = $ appPlugin ->getPluginInfo ($ plugin ->getTitle ());
887
+ /** @var Plugin $objPlugin */
888
+ $ objPlugin = $ pluginInfo ['obj ' ];
889
+ $ pluginInUrl = $ plugin ->getOrCreatePluginConfiguration ($ accessUrl );
890
+ $ configuration = $ pluginInUrl ->getConfiguration ();
891
+
892
+ if (!in_array ('menu_administrator ' , $ configuration ['regions ' ] ?? [])) {
893
+ continue ;
894
+ }
895
+
896
+ $ items [] = [
897
+ 'class ' => 'item-plugin- ' .$ pluginInfo ['title ' ],
898
+ 'url ' => $ objPlugin ->getAdminUrl (),
899
+ 'label ' => $ pluginInfo ['title ' ],
900
+ ];
901
+ }
902
+
903
+ return $ items ;
904
+ }
864
905
}
0 commit comments