|
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 Chamilo\CoreBundle\Controller\BaseController; |
|
10
|
|
|
use Chamilo\CoreBundle\ServiceHelper\AccessUrlHelper; |
|
11
|
|
|
use Chamilo\CoreBundle\Settings\SettingsManager; |
|
12
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted; |
|
13
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
14
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
15
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
|
16
|
|
|
|
|
17
|
|
|
#[Route('/admin')] |
|
18
|
|
|
class AdminController extends BaseController |
|
19
|
|
|
{ |
|
20
|
|
|
public function __construct( |
|
21
|
|
|
private readonly AccessUrlHelper $accessUrlHelper, |
|
22
|
|
|
) {} |
|
23
|
|
|
|
|
24
|
|
|
#[IsGranted('ROLE_ADMIN')] |
|
25
|
|
|
#[Route('/register-campus', name: 'admin_register_campus', methods: ['POST'])] |
|
26
|
|
|
public function registerCampus(Request $request, SettingsManager $settingsManager): Response |
|
27
|
|
|
{ |
|
28
|
|
|
$requestData = $request->toArray(); |
|
29
|
|
|
$doNotListCampus = (bool) $requestData['donotlistcampus']; |
|
30
|
|
|
|
|
31
|
|
|
$settingsManager->setUrl($this->accessUrlHelper->getCurrent()); |
|
32
|
|
|
$settingsManager->updateSetting('platform.registered', 'true'); |
|
33
|
|
|
|
|
34
|
|
|
$settingsManager->updateSetting( |
|
35
|
|
|
'platform.donotlistcampus', |
|
36
|
|
|
$doNotListCampus ? 'true' : 'false' |
|
37
|
|
|
); |
|
38
|
|
|
|
|
39
|
|
|
return new Response('', Response::HTTP_NO_CONTENT); |
|
40
|
|
|
} |
|
41
|
|
|
} |
|
42
|
|
|
|