Skip to content

Commit 53f1731

Browse files
committed
Minor: Format code
1 parent 05d1acd commit 53f1731

File tree

15 files changed

+200
-213
lines changed

15 files changed

+200
-213
lines changed

src/CoreBundle/Controller/AccessUrlController.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
namespace Chamilo\CoreBundle\Controller;
88

9-
use Chamilo\CoreBundle\Entity\User;
109
use Chamilo\CoreBundle\Entity\AccessUrl;
10+
use Chamilo\CoreBundle\Entity\User;
1111
use Doctrine\ORM\EntityManagerInterface;
1212
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1313
use Symfony\Component\HttpFoundation\Request;
@@ -38,25 +38,27 @@ public function importUsers(Request $request): Response
3838
while (($data = fgetcsv($handle, 1000, ',')) !== false) {
3939
$lineNumber++;
4040

41-
if ($lineNumber === 1 && strtolower(trim($data[0])) === 'username') {
41+
if (1 === $lineNumber && 'username' === strtolower(trim($data[0]))) {
4242
continue; // Skip header
4343
}
4444

45-
if (count($data) < 2) {
45+
if (\count($data) < 2) {
4646
$report[] = $this->formatReport('alert-circle', 'Line %s: invalid format. Two columns expected.', [$lineNumber]);
47+
4748
continue;
4849
}
4950

5051
[$username, $url] = array_map('trim', $data);
5152

5253
if (!$username || !$url) {
5354
$report[] = $this->formatReport('alert-circle', 'Line %s: missing username or URL.', [$lineNumber]);
55+
5456
continue;
5557
}
5658

5759
// Normalize URL
5860
if (!str_starts_with($url, 'http')) {
59-
$url = 'https://' . $url;
61+
$url = 'https://'.$url;
6062
}
6163
if (!str_ends_with($url, '/')) {
6264
$url .= '/';
@@ -65,12 +67,14 @@ public function importUsers(Request $request): Response
6567
$user = $this->em->getRepository(User::class)->findOneBy(['username' => $username]);
6668
if (!$user) {
6769
$report[] = $this->formatReport('close-circle', "Line %s: user '%s' not found.", [$lineNumber, $username]);
70+
6871
continue;
6972
}
7073

7174
$accessUrl = $this->em->getRepository(AccessUrl::class)->findOneBy(['url' => $url]);
7275
if (!$accessUrl) {
7376
$report[] = $this->formatReport('close-circle', "Line %s: URL '%s' not found.", [$lineNumber, $url]);
77+
7478
continue;
7579
}
7680

@@ -107,19 +111,20 @@ public function removeUsers(Request $request): Response
107111
while (($data = fgetcsv($handle, 1000, ',')) !== false) {
108112
$lineNumber++;
109113

110-
if ($lineNumber === 1 && strtolower(trim($data[0])) === 'username') {
114+
if (1 === $lineNumber && 'username' === strtolower(trim($data[0]))) {
111115
continue; // Skip header
112116
}
113117

114118
[$username, $url] = array_map('trim', $data);
115119

116120
if (!$username || !$url) {
117121
$report[] = $this->formatReport('alert-circle', 'Line %s: empty fields.', [$lineNumber]);
122+
118123
continue;
119124
}
120125

121126
if (!str_starts_with($url, 'http')) {
122-
$url = 'https://' . $url;
127+
$url = 'https://'.$url;
123128
}
124129
if (!str_ends_with($url, '/')) {
125130
$url .= '/';
@@ -128,19 +133,22 @@ public function removeUsers(Request $request): Response
128133
$user = $this->em->getRepository(User::class)->findOneBy(['username' => $username]);
129134
if (!$user) {
130135
$report[] = $this->formatReport('close-circle', "Line %s: user '%s' not found.", [$lineNumber, $username]);
136+
131137
continue;
132138
}
133139

134140
$accessUrl = $this->em->getRepository(AccessUrl::class)->findOneBy(['url' => $url]);
135141
if (!$accessUrl) {
136142
$report[] = $this->formatReport('close-circle', "Line %s: URL '%s' not found.", [$lineNumber, $url]);
143+
137144
continue;
138145
}
139146

140147
foreach ($accessUrl->getUsers() as $rel) {
141148
if ($rel->getUser()->getId() === $user->getId()) {
142149
$this->em->remove($rel);
143150
$report[] = $this->formatReport('account-remove-outline', "Line %s: user '%s' removed from '%s'.", [$lineNumber, $username, $url]);
151+
144152
continue 2;
145153
}
146154
}
@@ -154,13 +162,14 @@ public function removeUsers(Request $request): Response
154162

155163
return $this->render('@ChamiloCore/AccessUrl/remove_users.html.twig', [
156164
'report' => $report,
157-
'title' => $this->translator->trans('Remove users from URLs from CSV')
165+
'title' => $this->translator->trans('Remove users from URLs from CSV'),
158166
]);
159167
}
160168

161169
private function formatReport(string $icon, string $message, array $params): string
162170
{
163171
$text = vsprintf($this->translator->trans($message), $params);
164-
return sprintf('<i class="mdi mdi-%s text-base me-1"></i> %s', $icon, $text);
172+
173+
return \sprintf('<i class="mdi mdi-%s text-base me-1"></i> %s', $icon, $text);
165174
}
166175
}

src/CoreBundle/Controller/Api/CreateUserOnAccessUrlAction.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ public function __invoke(CreateUserOnAccessUrlInput $data): User
101101

102102
if ($data->getSendEmail()) {
103103
$request = $this->requestStack->getCurrentRequest();
104-
$baseUrl = $request->getSchemeAndHttpHost() . $request->getBasePath();
105-
$sessionUrl = rtrim($baseUrl, '/') . '/sessions';
104+
$baseUrl = $request->getSchemeAndHttpHost().$request->getBasePath();
105+
$sessionUrl = rtrim($baseUrl, '/').'/sessions';
106106
$platformName = $this->settingsManager->getSetting('platform.site_name', true);
107107
$password = $data->getPassword();
108108

@@ -112,13 +112,13 @@ public function __invoke(CreateUserOnAccessUrlInput $data): User
112112
);
113113

114114
$body = $this->translator->trans(
115-
'Hello %s,<br><br>' .
116-
'You are registered to %s.<br>' .
117-
'You can access your account from <a href="%s">here</a>.<br><br>' .
118-
'Your login credentials are:<br>' .
119-
'Username: <strong>%s</strong><br>' .
120-
'Password: <strong>%s</strong><br><br>' .
121-
'Best regards,<br>' .
115+
'Hello %s,<br><br>'.
116+
'You are registered to %s.<br>'.
117+
'You can access your account from <a href="%s">here</a>.<br><br>'.
118+
'Your login credentials are:<br>'.
119+
'Username: <strong>%s</strong><br>'.
120+
'Password: <strong>%s</strong><br><br>'.
121+
'Best regards,<br>'.
122122
'%s'
123123
);
124124

src/CoreBundle/Controller/ExceptionController.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ public function show(Exception $exception): Response
2929
throw new HttpException($exception->getCode(), $exception->getMessage());
3030
}
3131

32-
$name = 'exception';
33-
$code = $exception->getCode();
34-
$format = 'html';
35-
$loader = $this->container->get('twig')->getLoader();
36-
$templateToLoad = sprintf('@ChamiloCore/Exception/%s.html.twig', 'exception_full');
32+
$name = 'exception';
33+
$code = $exception->getCode();
34+
$format = 'html';
35+
$loader = $this->container->get('twig')->getLoader();
36+
$templateToLoad = \sprintf('@ChamiloCore/Exception/%s.html.twig', 'exception_full');
3737

38-
$candidate = sprintf('@ChamiloCore/Exception/%s%s.%s.twig', $name, $code, $format);
38+
$candidate = \sprintf('@ChamiloCore/Exception/%s%s.%s.twig', $name, $code, $format);
3939
if ($loader->exists($candidate)) {
4040
$templateToLoad = $candidate;
4141
}
4242

43-
$candidate = sprintf('@ChamiloCore/Exception/%s.%s.twig', $name, $format);
43+
$candidate = \sprintf('@ChamiloCore/Exception/%s.%s.twig', $name, $format);
4444
if ($loader->exists($candidate)) {
4545
$templateToLoad = $candidate;
4646
}
@@ -59,18 +59,18 @@ public function error(Request $request): Response
5959

6060
$exception->setMessage($message);
6161

62-
$name = 'exception';
63-
$code = $exception->getCode();
64-
$format = 'html';
65-
$loader = $this->container->get('twig')->getLoader();
66-
$templateToLoad = sprintf('@ChamiloCore/Exception/%s.html.twig', 'exception_full');
62+
$name = 'exception';
63+
$code = $exception->getCode();
64+
$format = 'html';
65+
$loader = $this->container->get('twig')->getLoader();
66+
$templateToLoad = \sprintf('@ChamiloCore/Exception/%s.html.twig', 'exception_full');
6767

68-
$candidate = sprintf('@ChamiloCore/Exception/%s%s.%s.twig', $name, $code, $format);
68+
$candidate = \sprintf('@ChamiloCore/Exception/%s%s.%s.twig', $name, $code, $format);
6969
if ($loader->exists($candidate)) {
7070
$templateToLoad = $candidate;
7171
}
7272

73-
$candidate = sprintf('@ChamiloCore/Exception/%s.%s.twig', $name, $format);
73+
$candidate = \sprintf('@ChamiloCore/Exception/%s.%s.twig', $name, $format);
7474
if ($loader->exists($candidate)) {
7575
$templateToLoad = $candidate;
7676
}
@@ -90,20 +90,20 @@ public function undefinedUrlError(Request $request): Response
9090
$themeName = 'chamilo';
9191

9292
$cssUrl = $themeHost
93-
. $this->urlGenerator->generate('theme_asset', [
93+
.$this->urlGenerator->generate('theme_asset', [
9494
'name' => $themeName,
9595
'path' => 'colors.css',
9696
], UrlGeneratorInterface::ABSOLUTE_PATH);
9797

9898
$logoUrl = $themeHost
99-
. $this->urlGenerator->generate('theme_asset', [
99+
.$this->urlGenerator->generate('theme_asset', [
100100
'name' => $themeName,
101101
'path' => 'images/header-logo.svg',
102102
], UrlGeneratorInterface::ABSOLUTE_PATH);
103103

104104
return $this->render('@ChamiloCore/Exception/undefined_url.html.twig', [
105-
'host' => $host,
106-
'cssUrl' => $cssUrl,
105+
'host' => $host,
106+
'cssUrl' => $cssUrl,
107107
'logoUrl' => $logoUrl,
108108
]);
109109
}

src/CoreBundle/Controller/SessionController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,8 @@ public function sendCourseNotification(
339339
}
340340

341341
$request = $this->requestStack->getCurrentRequest();
342-
$baseUrl = $request->getSchemeAndHttpHost() . $request->getBasePath();
343-
$sessionUrl = rtrim($baseUrl, '/') . '/sessions';
342+
$baseUrl = $request->getSchemeAndHttpHost().$request->getBasePath();
343+
$sessionUrl = rtrim($baseUrl, '/').'/sessions';
344344

345345
$subject = $this->translator->trans('You have been enrolled in a new course');
346346

src/CoreBundle/DataFixtures/SettingsCurrentFixtures.php

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,7 @@ public static function getExistingSettings(): array
10391039
[
10401040
'name' => 'push_notification_settings',
10411041
'title' => 'Push notification settings (JSON)',
1042-
'comment' => "JSON configuration for Push notifications integration.",
1042+
'comment' => 'JSON configuration for Push notifications integration.',
10431043
],
10441044
[
10451045
'name' => 'donotlistcampus',
@@ -1146,7 +1146,7 @@ public static function getExistingSettings(): array
11461146
[
11471147
'name' => 'mailer_dsn',
11481148
'title' => 'Mail DSN',
1149-
'comment' => sprintf(
1149+
'comment' => \sprintf(
11501150
'The DSN fully includes all parameters needed to connect to the mail service. You can learn more at %s. Here are a few examples of supported DSN syntaxes: %s',
11511151
'https://symfony.com/doc/6.4/mailer.html#using-built-in-transports',
11521152
'https://symfony.com/doc/6.4/mailer.html#using-a-3rd-party-transport'
@@ -1502,68 +1502,68 @@ public static function getNewConfigurationSettings(): array
15021502
return [
15031503
'catalog' => [
15041504
[
1505-
'name' => 'course_catalog_settings',
1506-
'title' => 'Course Catalog Settings',
1505+
'name' => 'course_catalog_settings',
1506+
'title' => 'Course Catalog Settings',
15071507
'comment' => 'JSON configuration for course catalog: link settings, filters, sort options, and more.',
15081508
],
15091509
[
1510-
'name' => 'session_catalog_settings',
1511-
'title' => 'Session Catalog Settings',
1510+
'name' => 'session_catalog_settings',
1511+
'title' => 'Session Catalog Settings',
15121512
'comment' => 'JSON configuration for session catalog: filters and display options.',
15131513
],
15141514
[
1515-
'name' => 'show_courses_descriptions_in_catalog',
1516-
'title' => 'Show Course Descriptions',
1515+
'name' => 'show_courses_descriptions_in_catalog',
1516+
'title' => 'Show Course Descriptions',
15171517
'comment' => 'Display course descriptions within the catalog listing.',
15181518
],
15191519
[
1520-
'name' => 'course_catalog_published',
1521-
'title' => 'Published Courses Only',
1520+
'name' => 'course_catalog_published',
1521+
'title' => 'Published Courses Only',
15221522
'comment' => 'Limit the catalog to only courses marked as published.',
15231523
],
15241524
[
1525-
'name' => 'course_catalog_display_in_home',
1526-
'title' => 'Display Catalog on Homepage',
1525+
'name' => 'course_catalog_display_in_home',
1526+
'title' => 'Display Catalog on Homepage',
15271527
'comment' => 'Show the course catalog block on the platform homepage.',
15281528
],
15291529
[
1530-
'name' => 'hide_public_link',
1531-
'title' => 'Hide Public Link',
1530+
'name' => 'hide_public_link',
1531+
'title' => 'Hide Public Link',
15321532
'comment' => 'Remove the public URL link from course cards.',
15331533
],
15341534
[
1535-
'name' => 'only_show_selected_courses',
1536-
'title' => 'Only Selected Courses',
1535+
'name' => 'only_show_selected_courses',
1536+
'title' => 'Only Selected Courses',
15371537
'comment' => 'Show only manually selected courses in the catalog.',
15381538
],
15391539
[
1540-
'name' => 'only_show_course_from_selected_category',
1541-
'title' => 'Only show matching categories in courses catalogue',
1540+
'name' => 'only_show_course_from_selected_category',
1541+
'title' => 'Only show matching categories in courses catalogue',
15421542
'comment' => 'When not empty, only the courses from the given categories will appear in the courses catalogue.',
15431543
],
15441544
[
1545-
'name' => 'allow_students_to_browse_courses',
1546-
'title' => 'Allow Student Browsing',
1545+
'name' => 'allow_students_to_browse_courses',
1546+
'title' => 'Allow Student Browsing',
15471547
'comment' => 'Permit students to browse and filter the course catalog.',
15481548
],
15491549
[
1550-
'name' => 'course_catalog_hide_private',
1551-
'title' => 'Hide Private Courses',
1550+
'name' => 'course_catalog_hide_private',
1551+
'title' => 'Hide Private Courses',
15521552
'comment' => 'Exclude private courses from the catalog display.',
15531553
],
15541554
[
1555-
'name' => 'show_courses_sessions',
1556-
'title' => 'Show Courses & Sessions',
1555+
'name' => 'show_courses_sessions',
1556+
'title' => 'Show Courses & Sessions',
15571557
'comment' => 'Include both courses and sessions in catalog results.',
15581558
],
15591559
[
1560-
'name' => 'allow_session_auto_subscription',
1561-
'title' => 'Auto Session Subscription',
1560+
'name' => 'allow_session_auto_subscription',
1561+
'title' => 'Auto Session Subscription',
15621562
'comment' => 'Enable automatic subscription to sessions for users.',
15631563
],
15641564
[
1565-
'name' => 'course_subscription_in_user_s_session',
1566-
'title' => 'Subscription in Session View',
1565+
'name' => 'course_subscription_in_user_s_session',
1566+
'title' => 'Subscription in Session View',
15671567
'comment' => 'Allow users to subscribe to courses directly from their session page.',
15681568
],
15691569
],

0 commit comments

Comments
 (0)