Add declare(strict_types=1), fix type hints

pull/3844/head
Julio Montoya 4 years ago
parent 06a8ecaf2b
commit c3ff0e276f
  1. 2
      src/CoreBundle/Controller/AbstractResourceController.php
  2. 2
      src/CoreBundle/Controller/AccountController.php
  3. 54
      src/CoreBundle/Controller/Admin/AdminController.php
  4. 7
      src/CoreBundle/Controller/Admin/PluginsController.php
  5. 13
      src/CoreBundle/Controller/Admin/SettingsController.php
  6. 21
      src/CoreBundle/Controller/Api/CreateResourceNodeFileAction.php
  7. 11
      src/CoreBundle/Controller/Api/UpdateResourceNodeFileAction.php
  8. 4
      src/CoreBundle/Controller/AssetController.php
  9. 2
      src/CoreBundle/Controller/BaseController.php
  10. 14
      src/CoreBundle/Controller/ChatController.php
  11. 8
      src/CoreBundle/Controller/CourseController.php
  12. 38
      src/CoreBundle/Controller/CourseHomeController.php
  13. 2
      src/CoreBundle/Controller/CreateResourceFileAction.php
  14. 5
      src/CoreBundle/Controller/EditorController.php
  15. 2
      src/CoreBundle/Controller/ExceptionController.php
  16. 2
      src/CoreBundle/Controller/IndexController.php
  17. 27
      src/CoreBundle/Controller/NewsController.php
  18. 9
      src/CoreBundle/Controller/OnlineController.php
  19. 6
      src/CoreBundle/Controller/ResetPasswordController.php
  20. 4
      src/CoreBundle/Controller/ResourceApiController.php
  21. 10
      src/CoreBundle/Controller/ResourceController.php
  22. 2
      src/CoreBundle/Controller/ResourceUploadController.php
  23. 4
      src/CoreBundle/Controller/SecurityController.php
  24. 19
      src/CoreBundle/Controller/SessionController.php
  25. 2
      src/CoreBundle/Controller/ToolController.php
  26. 2
      src/CoreBundle/Controller/UserController.php
  27. 2
      src/CoreBundle/DataProvider/Extension/CDocumentExtension.php

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Controller;

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Controller;

@ -1,10 +1,14 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Controller\Admin;
use Chamilo\CoreBundle\Controller\BaseController;
use Display;
use FormValidator;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
@ -37,11 +41,11 @@ class AdminController extends BaseController
/**
* @param string $url
*
* @return \FormValidator
* @return FormValidator
*/
private function getSearchForm($url)
{
$form = new \FormValidator(
$form = new FormValidator(
'search-form',
'get',
$url,
@ -66,7 +70,7 @@ class AdminController extends BaseController
$blocks = [];
/* Users */
$blocks['users']['icon'] = \Display::return_icon(
$blocks['users']['icon'] = Display::return_icon(
'members.png',
get_lang('Users'),
[],
@ -127,7 +131,7 @@ class AdminController extends BaseController
if (api_is_platform_admin()) {
/* Courses */
$blocks['courses']['icon'] = \Display::return_icon(
$blocks['courses']['icon'] = Display::return_icon(
'course.png',
get_lang('Courses'),
[],
@ -206,7 +210,7 @@ class AdminController extends BaseController
$blocks['courses']['extra'] = null;
/* Portal */
$blocks['platform']['icon'] = \Display::return_icon(
$blocks['platform']['icon'] = Display::return_icon(
'platform.png',
get_lang('Portal'),
[],
@ -241,8 +245,8 @@ class AdminController extends BaseController
];
$items[] = [
'url' => api_get_path(
WEB_CODE_PATH
).'calendar/agenda_js.php?type=admin',
WEB_CODE_PATH
).'calendar/agenda_js.php?type=admin',
'label' => get_lang('Global agenda'),
];
$items[] = [
@ -259,18 +263,16 @@ class AdminController extends BaseController
];
$items[] = [
'url' => api_get_path(
WEB_CODE_PATH
).'mySpace/company_reports.php',
WEB_CODE_PATH
).'mySpace/company_reports.php',
'label' => get_lang('Reports'),
];
if (api_get_multiple_access_url()) {
if (api_is_global_platform_admin()) {
$items[] = [
'url' => $adminUrl.'access_urls.php',
'label' => get_lang('Configure multiple access URL'),
];
}
if (api_get_multiple_access_url() && api_is_global_platform_admin()) {
$items[] = [
'url' => $adminUrl.'access_urls.php',
'label' => get_lang('Configure multiple access URL'),
];
}
if ('true' ==
@ -286,7 +288,7 @@ class AdminController extends BaseController
}
/* Course sessions */
$blocks['sessions']['icon'] = \Display::return_icon(
$blocks['sessions']['icon'] = Display::return_icon(
'session.png',
get_lang('Course sessions'),
[],
@ -301,14 +303,14 @@ class AdminController extends BaseController
$items = [];
$items[] = [
'url' => api_get_path(
WEB_CODE_PATH
).'session/session_list.php',
WEB_CODE_PATH
).'session/session_list.php',
'label' => get_lang('Training sessions list'),
];
$items[] = [
'url' => api_get_path(
WEB_CODE_PATH
).'session/session_add.php',
WEB_CODE_PATH
).'session/session_add.php',
'label' => get_lang('Add a training session'),
];
$items[] = [
@ -358,7 +360,7 @@ class AdminController extends BaseController
/* Settings */
if (api_is_platform_admin()) {
$blocks['settings']['icon'] = \Display::return_icon(
$blocks['settings']['icon'] = Display::return_icon(
'settings.png',
get_lang('System'),
[],
@ -402,7 +404,7 @@ class AdminController extends BaseController
//Skills
if ('true' == api_get_setting('skill.allow_skills_tool')) {
$blocks['skills']['icon'] = \Display::return_icon(
$blocks['skills']['icon'] = Display::return_icon(
'skill-badges.png',
get_lang('Skills'),
[],
@ -424,8 +426,8 @@ class AdminController extends BaseController
//$items[] = array('url' => $adminUrl.'skills_profile.php', 'label' => get_lang('Skills Profile'));
$items[] = [
'url' => api_get_path(
WEB_CODE_PATH
).'social/skills_ranking.php',
WEB_CODE_PATH
).'social/skills_ranking.php',
'label' => get_lang('Skills ranking'),
];
$items[] = [
@ -438,7 +440,7 @@ class AdminController extends BaseController
}
/* Chamilo.org */
$blocks['chamilo']['icon'] = \Display::return_icon(
$blocks['chamilo']['icon'] = Display::return_icon(
'platform.png',
'Chamilo.org',
[],

@ -1,9 +1,12 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Controller\Admin;
use AppPlugin;
use Chamilo\CoreBundle\Controller\BaseController;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\Routing\Annotation\Route;
@ -17,7 +20,7 @@ class PluginsController extends BaseController
*/
public function pluginsAction()
{
$appPlugin = new \AppPlugin();
$appPlugin = new AppPlugin();
$installedPlugins = $appPlugin->getInstalledPlugins();
return $this->render(
@ -35,7 +38,7 @@ class PluginsController extends BaseController
*/
public function pluginsAddAction()
{
$appPlugin = new \AppPlugin();
$appPlugin = new AppPlugin();
$allPlugins = $appPlugin->read_plugins_from_path();
$allPluginsList = [];
foreach ($allPlugins as $pluginName) {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Controller\Admin;
@ -10,6 +12,7 @@ use Chamilo\CoreBundle\Traits\ControllerTrait;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
@ -77,7 +80,7 @@ class SettingsController extends BaseController
$schemaAlias = $manager->convertNameSpaceToService($category);
$form = $this->getSettingsFormFactory()->create($schemaAlias);
foreach ($settings->getParameters() as $name => $value) {
foreach (array_keys($settings->getParameters()) as $name) {
if (!in_array($name, $list)) {
$form->remove($name);
$settings->remove($name);
@ -148,8 +151,8 @@ class SettingsController extends BaseController
if (!empty($keyword)) {
$params = $settings->getParameters();
foreach ($params as $name => $value) {
if (!in_array($name, array_keys($settingsFromKeyword))) {
foreach (array_keys($params) as $name) {
if (!array_key_exists($name, $settingsFromKeyword)) {
$form->remove($name);
}
}
@ -192,7 +195,7 @@ class SettingsController extends BaseController
/**
* Sync settings from classes with the database.
*/
public function syncSettings(Request $request)
public function syncSettings(Request $request): void
{
$manager = $this->getSettingsManager();
// @todo improve get the current url entity
@ -203,7 +206,7 @@ class SettingsController extends BaseController
}
/**
* @return \Symfony\Component\Form\FormInterface
* @return FormInterface
*/
private function getSearchForm()
{

@ -1,10 +1,13 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Controller\Api;
use Chamilo\CourseBundle\Entity\CDocument;
use InvalidArgumentException;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
@ -43,7 +46,7 @@ class CreateResourceNodeFileAction
$fileParsed = false;
// File upload.
if ($request->files->count() > 0) {
if (false === $request->files->has('uploadFile')) {
if (!$request->files->has('uploadFile')) {
throw new BadRequestHttpException('"uploadFile" is required');
}
@ -55,7 +58,7 @@ class CreateResourceNodeFileAction
}
// Get data in content and create a HTML file.
if (false === $fileParsed && $content) {
if (!$fileParsed && $content) {
$handle = tmpfile();
fwrite($handle, $content);
$meta = stream_get_meta_data($handle);
@ -64,8 +67,8 @@ class CreateResourceNodeFileAction
$fileParsed = true;
}
if (false === $fileParsed) {
throw new \InvalidArgumentException('filetype was set to "file" but not upload found');
if (!$fileParsed) {
throw new InvalidArgumentException('filetype was set to "file" but not upload found');
}
break;
@ -75,21 +78,17 @@ class CreateResourceNodeFileAction
}
if (empty($title)) {
throw new \InvalidArgumentException('title required');
throw new InvalidArgumentException('title required');
}
$document->setTitle($title);
if ($request->request->has('resourceLinkList')) {
$links = $request->get('resourceLinkList');
if (false === strpos($links, '[')) {
$links = json_decode('['.$links.']', true);
} else {
$links = json_decode($links, true);
}
$links = false === strpos($links, '[') ? json_decode('['.$links.']', true) : json_decode($links, true);
if (empty($links)) {
$message = 'resourceLinkList is not a valid json. Use for example: [{"c_id":1, "visibility":1}]';
throw new \InvalidArgumentException($message);
throw new InvalidArgumentException($message);
}
$document->setResourceLinkArray($links);
}

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Controller\Api;
@ -7,6 +9,7 @@ namespace Chamilo\CoreBundle\Controller\Api;
use Chamilo\CoreBundle\Entity\ResourceLink;
use Chamilo\CourseBundle\Entity\CDocument;
use Chamilo\CourseBundle\Repository\CDocumentRepository;
use DateTime;
use Symfony\Component\HttpFoundation\Request;
class UpdateResourceNodeFileAction
@ -38,8 +41,8 @@ class UpdateResourceNodeFileAction
$resourceNode->setContent($content);
$resourceNode->getResourceFile()->setSize(strlen($content));
}
$resourceNode->setUpdatedAt(new \DateTime());
$resourceNode->getResourceFile()->setUpdatedAt(new \DateTime());
$resourceNode->setUpdatedAt(new DateTime());
$resourceNode->getResourceFile()->setUpdatedAt(new DateTime());
$document->setResourceNode($resourceNode);
}
@ -51,9 +54,7 @@ class UpdateResourceNodeFileAction
/** @var ResourceLink $link */
$link = $document->getResourceNode()->getResourceLinks()
->filter(
function ($link) use ($linkId) {
return $link->getId() === $linkId;
}
fn ($link) => $link->getId() === $linkId
)->first();
if (null !== $link) {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Controller;
@ -23,7 +25,7 @@ class AssetController
use ControllerTrait;
/**
* @Route("/{category}/{path}", methods={"GET"}, requirements={"path"=".+"}, name="chamilo_core_asset_showfile")
* @Route("/{category}/{path}", methods={"GET"}, requirements={"path"=".+"}, name="chamilo_core_asset_showfile")
*/
public function showFile($category, $path, AssetRepository $assetRepository)
{

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Controller;

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Controller;
@ -10,6 +12,8 @@ use Chamilo\CoreBundle\Traits\CourseControllerTrait;
use Chamilo\CoreBundle\Traits\ResourceControllerTrait;
use Chamilo\CourseBundle\Controller\CourseControllerInterface;
use Chamilo\CourseBundle\Repository\CChatConversationRepository;
use CourseChatUtils;
use Event;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@ -29,14 +33,14 @@ class ChatController extends AbstractResourceController implements CourseControl
*/
public function indexAction(Request $request): Response
{
\Event::event_access_tool(TOOL_CHAT);
Event::event_access_tool(TOOL_CHAT);
$logInfo = [
'tool' => TOOL_CHAT,
'action' => 'start',
'action_details' => 'start-chat',
];
\Event::registerLog($logInfo);
Event::registerLog($logInfo);
return $this->render(
'@ChamiloCore/Chat/chat.html.twig',
@ -66,7 +70,7 @@ class ChatController extends AbstractResourceController implements CourseControl
$json = ['status' => false];
$parentResourceNode = $this->getParentResourceNode($request);
$courseChatUtils = new \CourseChatUtils(
$courseChatUtils = new CourseChatUtils(
$courseId,
$userId,
$sessionId,
@ -84,7 +88,7 @@ class ChatController extends AbstractResourceController implements CourseControl
'action' => 'exit',
'action_details' => 'exit-chat',
];
\Event::registerLog($logInfo);
Event::registerLog($logInfo);
break;
case 'track':
@ -105,7 +109,7 @@ class ChatController extends AbstractResourceController implements CourseControl
'oldFileSize' => false,
'history' => $courseChatUtils->readMessages(false, $friend),
'usersOnline' => $newUsersOnline,
'userList' => $newUsersOnline != $oldUsersOnline ? $courseChatUtils->listUsersOnline() : null,
'userList' => $newUsersOnline !== $oldUsersOnline ? $courseChatUtils->listUsersOnline() : null,
'currentFriend' => $friend,
],
];

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Controller;
@ -11,7 +13,9 @@ use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CoreBundle\Repository\ExtraFieldRelTagRepository;
use Chamilo\CoreBundle\Repository\Node\IllustrationRepository;
use Chamilo\CourseBundle\Entity\CCourseDescription;
use CourseManager;
use Doctrine\ORM\EntityRepository;
use ExtraFieldValue;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Entity;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
@ -76,7 +80,7 @@ class CourseController extends AbstractController
]
);
$courseValues = new \ExtraFieldValue('course');
$courseValues = new ExtraFieldValue('course');
$urlCourse = api_get_path(WEB_PATH)."course/$courseId/about";
$courseTeachers = $course->getTeachers();
@ -154,7 +158,7 @@ class CourseController extends AbstractController
'custom' => array_reverse($courseCustom),
];
$subscriptionUser = \CourseManager::is_user_subscribed_in_course($userId, $course->getCode());
$subscriptionUser = CourseManager::is_user_subscribed_in_course($userId, $course->getCode());
/*$allowSubscribe = false;
if ($course->getSubscribe() || api_is_platform_admin()) {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Controller;
@ -16,6 +18,8 @@ use Chamilo\CourseBundle\Repository\CToolRepository;
use CourseManager;
use Database;
use Display;
use Event;
use Exercise;
use ExtraFieldValue;
use Fhaculty\Graph\Graph;
use Security;
@ -76,34 +80,28 @@ class CourseHomeController extends ToolBaseController
$isSpecialCourse = CourseManager::isSpecialCourse($courseId);
if ($user && $isSpecialCourse) {
if (isset($_GET['autoreg']) && 1 === (int) $_GET['autoreg']) {
if (CourseManager::subscribeUser($userId, $courseCode, STUDENT)) {
$session->set('is_allowed_in_course', true);
}
if ($user && $isSpecialCourse && (isset($_GET['autoreg']) && 1 === (int) $_GET['autoreg'])) {
if (CourseManager::subscribeUser($userId, $courseCode, STUDENT)) {
$session->set('is_allowed_in_course', true);
}
}
$action = !empty($_GET['action']) ? Security::remove_XSS($_GET['action']) : '';
if ('subscribe' === $action) {
if (Security::check_token('get')) {
Security::clear_token();
$result = CourseManager::autoSubscribeToCourse($courseCode);
if ($result) {
if (CourseManager::is_user_subscribed_in_course($userId, $courseCode)) {
$session->set('is_allowed_in_course', true);
}
}
header('Location: '.api_get_self());
exit;
$action = empty($_GET['action']) ? '' : Security::remove_XSS($_GET['action']);
if ('subscribe' === $action && Security::check_token('get')) {
Security::clear_token();
$result = CourseManager::autoSubscribeToCourse($courseCode);
if ($result && CourseManager::is_user_subscribed_in_course($userId, $courseCode)) {
$session->set('is_allowed_in_course', true);
}
header('Location: '.api_get_self());
exit;
}
$logInfo = [
'tool' => 'course-main',
'action' => $action,
];
\Event::registerLog($logInfo);
Event::registerLog($logInfo);
/* Introduction section (editable by course admins) */
/*$introduction = Display::return_introduction_section(
@ -186,7 +184,7 @@ class CourseHomeController extends ToolBaseController
$session->remove('lpobject');
api_remove_in_gradebook();
\Exercise::cleanSessionVariables();
Exercise::cleanSessionVariables();
$shortcuts = [];
if ($user) {
@ -283,7 +281,7 @@ class CourseHomeController extends ToolBaseController
);
}
private function autoLaunch()
private function autoLaunch(): void
{
/* Auto launch code */
$autoLaunchWarning = '';

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Controller;

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Controller;
@ -14,6 +16,7 @@ use Chamilo\CoreBundle\Settings\SettingsManager;
use Chamilo\CoreBundle\Traits\ControllerTrait;
use Chamilo\CoreBundle\Traits\CourseControllerTrait;
use Chamilo\CoreBundle\Traits\ResourceControllerTrait;
use Chat;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
@ -57,7 +60,7 @@ class EditorController extends BaseController
*/
public function editorFileManager(): Response
{
\Chat::setDisableChat();
Chat::setDisableChat();
$params = [
'course_condition' => '?'.$this->getCourseUrlQuery(),
];

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Controller;

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Controller;

@ -1,12 +1,16 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Controller;
use Chamilo\CoreBundle\Traits\ControllerTrait;
use Display;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use SystemAnnouncementManager;
/**
* Class IndexController
@ -25,11 +29,11 @@ class NewsController extends BaseController
{
$toolBar = '';
if ($this->isGranted('ROLE_ADMIN')) {
$actionEdit = \Display::url(
\Display::return_icon('edit.png', $this->trans('EditSystemAnnouncement'), [], ICON_SIZE_MEDIUM),
$actionEdit = Display::url(
Display::return_icon('edit.png', $this->trans('EditSystemAnnouncement'), [], ICON_SIZE_MEDIUM),
api_get_path(WEB_PATH).'main/admin/system_announcements.php'
);
$toolBar = \Display::toolbarAction('toolbar', [$actionEdit]);
$toolBar = Display::toolbarAction('toolbar', [$actionEdit]);
}
return $this->render(
@ -47,10 +51,10 @@ class NewsController extends BaseController
*/
public function newsAction($id = 0): Response
{
$visibility = \SystemAnnouncementManager::getCurrentUserVisibility();
$visibility = SystemAnnouncementManager::getCurrentUserVisibility();
if (empty($id)) {
$content = \SystemAnnouncementManager::getAnnouncements($visibility);
$content = SystemAnnouncementManager::getAnnouncements($visibility);
return $this->render(
'@ChamiloCore/News/slider.html.twig',
@ -58,15 +62,14 @@ class NewsController extends BaseController
'announcements' => $content,
]
);
} else {
$content = \SystemAnnouncementManager::getAnnouncement($id, $visibility);
}
$content = SystemAnnouncementManager::getAnnouncement($id, $visibility);
return $this->render(
'@ChamiloCore/News/view.html.twig',
[
return $this->render(
'@ChamiloCore/News/view.html.twig',
[
'announcement' => $content,
]
);
}
);
}
}

@ -1,9 +1,12 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Controller;
use SocialManager;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
@ -22,7 +25,7 @@ class OnlineController extends BaseController
{
// @todo don't use legacy code
$users = who_is_online(0, MAX_ONLINE_USERS);
$users = \SocialManager::display_user_list($users);
$users = SocialManager::display_user_list($users);
return $this->render(
'@ChamiloCore/Online/index.html.twig',
@ -46,7 +49,7 @@ class OnlineController extends BaseController
$cidReq
);
$users = \SocialManager::display_user_list($users);
$users = SocialManager::display_user_list($users);
return $this->render(
'@ChamiloCore/Online/index.html.twig',
@ -71,7 +74,7 @@ class OnlineController extends BaseController
$_GET['cidReq']
);
$users = \SocialManager::display_user_list($users);
$users = SocialManager::display_user_list($users);
return $this->render(
'@ChamiloCore/Online/index.html.twig',

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Chamilo\CoreBundle\Controller;
use Chamilo\CoreBundle\Entity\User;
@ -25,7 +27,7 @@ class ResetPasswordController extends AbstractController
{
use ResetPasswordControllerTrait;
private $resetPasswordHelper;
private ResetPasswordHelperInterface $resetPasswordHelper;
public function __construct(ResetPasswordHelperInterface $resetPasswordHelper)
{
@ -137,7 +139,7 @@ class ResetPasswordController extends AbstractController
]);
// Do not reveal whether a user account was found or not.
if (!$user) {
if (null === $user) {
return $this->redirectToRoute('app_check_email');
}

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Controller;
@ -75,7 +77,7 @@ class ResourceApiController extends AbstractController implements CourseControll
return $resource->getResourceNode()->getComments()->matching($criteria);
}
public function postResourceCommentAction($id, Request $request)
public function postResourceCommentAction($id, Request $request): void
{
$repository = $this->getRepositoryFromRequest($request);

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Controller;
@ -89,7 +91,7 @@ class ResourceController extends AbstractResourceController implements CourseCon
*
* If node has children show it
*/
public function listAction(Request $request)
public function listAction(Request $request): void
{
/*$tool = $request->get('tool');
$type = $request->get('type');
@ -615,7 +617,7 @@ class ResourceController extends AbstractResourceController implements CourseCon
}
$response = new StreamedResponse(
function () use ($zipName, $children, $repo) {
function () use ($zipName, $children, $repo): void {
// Define suitable options for ZipStream Archive.
$options = new Archive();
$options->setContentType('application/octet-stream');
@ -649,7 +651,7 @@ class ResourceController extends AbstractResourceController implements CourseCon
* Upload form.
*
* @Route("/{tool}/{type}/{id}/upload", name="chamilo_core_resource_upload", methods={"GET", "POST"},
* options={"expose"=true})
* options={"expose"=true})
*/
public function uploadAction(Request $request, $tool, $type, $id): Response
{
@ -685,7 +687,7 @@ class ResourceController extends AbstractResourceController implements CourseCon
$resourceFile = $resourceNode->getResourceFile();
if (!$resourceFile) {
if (null === $resourceFile) {
throw new NotFoundHttpException($this->trans('File not found for resource'));
}

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Controller;

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Controller;
@ -18,7 +20,7 @@ use Symfony\Component\Serializer\SerializerInterface;
*/
class SecurityController extends AbstractController
{
private $serializer;
private SerializerInterface $serializer;
public function __construct(SerializerInterface $serializer)
{

@ -1,9 +1,12 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Controller;
use BuyCoursesPlugin;
use Chamilo\CoreBundle\Entity\ExtraField;
use Chamilo\CoreBundle\Entity\ExtraFieldRelTag;
use Chamilo\CoreBundle\Entity\SequenceResource;
@ -16,6 +19,7 @@ use Chamilo\CoreBundle\Repository\Node\IllustrationRepository;
use Chamilo\CoreBundle\Repository\Node\UserRepository;
use Chamilo\CoreBundle\Repository\SequenceRepository;
use Chamilo\CourseBundle\Entity\CCourseDescription;
use CourseDescription;
use Doctrine\ORM\EntityRepository;
use Essence\Essence;
use ExtraFieldValue;
@ -25,6 +29,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use UserManager;
/**
* Class SessionController.
@ -80,7 +85,7 @@ class SessionController extends AbstractController
/** @var User $courseCoach */
foreach ($courseCoaches as $courseCoach) {
$coachData = [
'complete_name' => \UserManager::formatUserFullName($courseCoach),
'complete_name' => UserManager::formatUserFullName($courseCoach),
'image' => $illustrationRepo->getIllustrationUrl($courseCoach),
'diploma' => $courseCoach->getDiplomas(),
'openarea' => $courseCoach->getOpenarea(),
@ -94,7 +99,7 @@ class SessionController extends AbstractController
$coachesData[] = $coachData;
}
$cd = new \CourseDescription();
$cd = new CourseDescription();
$cd->set_course_id($sessionCourse->getId());
$cd->set_session_id($session->getId());
$descriptionsData = $cd->get_description_data();
@ -195,15 +200,15 @@ class SessionController extends AbstractController
}
}*/
$plugin = \BuyCoursesPlugin::create();
$plugin = BuyCoursesPlugin::create();
$checker = $plugin->isEnabled();
$sessionIsPremium = null;
if ($checker) {
$sessionIsPremium = $plugin->getItemByProduct(
$sessionId,
\BuyCoursesPlugin::PRODUCT_TYPE_SESSION
BuyCoursesPlugin::PRODUCT_TYPE_SESSION
);
if ($sessionIsPremium) {
if ([] !== $sessionIsPremium) {
$requestSession->set('SessionIsPremium', true);
$requestSession->set('sessionId', $sessionId);
}
@ -212,7 +217,7 @@ class SessionController extends AbstractController
$redirectToSession = api_get_configuration_value('allow_redirect_to_session_after_inscription_about');
$redirectToSession = $redirectToSession ? '?s='.$sessionId : false;
$coursesInThisSession = \SessionManager::get_course_list_by_session_id($sessionId);
$coursesInThisSession = SessionManager::get_course_list_by_session_id($sessionId);
$coursesCount = count($coursesInThisSession);
$redirectToSession = 1 === $coursesCount && $redirectToSession
? ($redirectToSession.'&cr='.array_values($coursesInThisSession)[0]['directory'])
@ -229,7 +234,7 @@ class SessionController extends AbstractController
//'has_requirements' => $hasRequirements,
//'sequences' => $sessionRequirements,
'is_premium' => $sessionIsPremium,
'show_tutor' => 'true' === api_get_setting('show_session_coach') ? true : false,
'show_tutor' => 'true' === api_get_setting('show_session_coach'),
'page_url' => api_get_path(WEB_PATH)."sessions/{$session->getId()}/about/",
'session_date' => $sessionDates,
'is_subscribed' => SessionManager::isUserSubscribedAsStudent(

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Controller;

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Controller;

@ -16,7 +16,7 @@ use Symfony\Component\Security\Core\Security;
final class CDocumentExtension implements QueryCollectionExtensionInterface //, QueryItemExtensionInterface
{
private $security;
private Security $security;
public function __construct(Security $security)
{

Loading…
Cancel
Save