Minor: Format code

pull/5264/head
Angel Fernando Quiroz Campos 2 years ago
parent 6a6d3f814d
commit d0b843daf3
  1. 1
      src/CoreBundle/Component/Utils/ChamiloApi.php
  2. 8
      src/CoreBundle/Controller/SocialController.php
  3. 2
      src/CoreBundle/Entity/Language.php
  4. 5
      src/CoreBundle/EventListener/ExceptionListener.php
  5. 3
      src/CoreBundle/Exception/NotAllowedException.php
  6. 8
      src/CoreBundle/Migrations/Schema/V200/Version20240310160200.php
  7. 4
      src/CoreBundle/Migrations/Schema/V200/Version20240318105600.php
  8. 16
      src/CoreBundle/Repository/Node/UserRepository.php
  9. 6
      src/CourseBundle/Entity/CAttendanceResultComment.php

@ -442,6 +442,7 @@ class ChamiloApi
{
if (!empty($url)) {
header("Location: $url");
exit;
}
}

@ -272,10 +272,10 @@ class SocialController extends AbstractController
UserManager::update_extra_field_value($userId, $justificationFieldToUpdate, $explanation);
$request = $requestStack->getCurrentRequest();
$baseUrl = $request->getSchemeAndHttpHost() . $request->getBasePath();
$baseUrl = $request->getSchemeAndHttpHost().$request->getBasePath();
$specificPath = '/main/admin/user_list_consent.php';
$link = $baseUrl . $specificPath;
$emailContent .= $translator->trans('Go here : '). '<a href="' . $link . '">' . $link . '</a>';
$link = $baseUrl.$specificPath;
$emailContent .= $translator->trans('Go here : ').'<a href="'.$link.'">'.$link.'</a>';
$emailOfficer = $settingsManager->getSetting('profile.data_protection_officer_email');
if (!empty($emailOfficer)) {
@ -666,7 +666,7 @@ class SocialController extends AbstractController
'status' => $isUserOnline ? 'online' : 'offline',
'url' => '/social?id='.$item['id'],
'relationType' => $relation['relationType'] ?? null,
'existingInvitations' => $existingInvitations
'existingInvitations' => $existingInvitations,
];
}
} elseif ('group' === $type) {

@ -20,7 +20,7 @@ use Symfony\Component\Validator\Constraints as Assert;
/**
* Platform languages.
*/
#[ApiResource(attributes: ["pagination_enabled" => false])]
#[ApiResource(attributes: ['pagination_enabled' => false])]
#[ApiFilter(BooleanFilter::class, properties: ['available'])]
#[ApiFilter(OrderFilter::class, properties: ['english_name' => 'DESC'])]
#[ORM\Table(name: 'language', options: ['row_format' => 'DYNAMIC'])]

@ -13,7 +13,6 @@ use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Twig\Environment;
class ExceptionListener
@ -39,10 +38,10 @@ class ExceptionListener
if (null === $this->tokenStorage->getToken()) {
$currentUrl = $request->getUri();
$parsedUrl = parse_url($currentUrl);
$baseUrl = $parsedUrl['scheme'] . '://' . $parsedUrl['host'];
$baseUrl = $parsedUrl['scheme'].'://'.$parsedUrl['host'];
$path = rtrim($parsedUrl['path'], '/') ?: '';
$query = $parsedUrl['query'] ?? '';
$redirectUrl = $baseUrl . $path . ($query ? '?' . $query : '');
$redirectUrl = $baseUrl.$path.($query ? '?'.$query : '');
$loginUrl = $this->router->generate('login', ['redirect' => $redirectUrl], UrlGeneratorInterface::ABSOLUTE_URL);
ChamiloApi::redirectTo($loginUrl);

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
declare(strict_types=1);
@ -9,7 +10,7 @@ use Exception;
class NotAllowedException extends Exception
{
public function __construct($message = 'Not allowed', $code = 0, Exception $previous = null)
public function __construct($message = 'Not allowed', $code = 0, ?Exception $previous = null)
{
parent::__construct($message, $code, $previous);
}

@ -1,6 +1,5 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
@ -12,6 +11,8 @@ use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Chamilo\CoreBundle\Repository\Node\UserRepository;
use Doctrine\DBAL\Schema\Schema;
use const PASSWORD_DEFAULT;
class Version20240310160200 extends AbstractMigrationChamilo
{
public function getDescription(): string
@ -26,7 +27,7 @@ class Version20240310160200 extends AbstractMigrationChamilo
$em = $doctrine->getManager();
/* @var UserRepository $repo*/
/** @var UserRepository $repo */
$repo = $container->get(UserRepository::class);
$plainPassword = 'fallback_user';
@ -46,7 +47,8 @@ class Version20240310160200 extends AbstractMigrationChamilo
->setPhone('0000000000')
->setLocale('en')
->setActive(User::SOFT_DELETED)
->setTimezone('UTC');
->setTimezone('UTC')
;
$em->flush();
error_log($fallbackUser->getFullname());

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
declare(strict_types=1);
@ -10,9 +11,6 @@ use Doctrine\DBAL\Schema\Schema;
class Version20240318105600 extends AbstractMigrationChamilo
{
/**
* @inheritDoc
*/
public function up(Schema $schema): void
{
$this->addSql("CREATE TABLE color_theme (id INT AUTO_INCREMENT NOT NULL, variables LONGTEXT NOT NULL COMMENT '(DC2Type:json)', created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', updated_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC");

@ -29,6 +29,7 @@ use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ManagerRegistry;
use Exception;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
@ -166,8 +167,9 @@ class UserRepository extends ResourceRepository implements PasswordUpgraderInter
$em->flush();
$em->getConnection()->commit();
} catch (\Exception $e) {
} catch (Exception $e) {
$em->getConnection()->rollBack();
throw $e;
}
}
@ -289,17 +291,17 @@ class UserRepository extends ResourceRepository implements PasswordUpgraderInter
];
foreach ($relations as $relation) {
$entityClass = 'Chamilo\\' . $relation['bundle'] . '\\Entity\\' . $relation['entity'];
$entityClass = 'Chamilo\\'.$relation['bundle'].'\\Entity\\'.$relation['entity'];
$repository = $em->getRepository($entityClass);
$records = $repository->findBy([$relation['field'] => $userToDelete]);
foreach ($records as $record) {
$setter = 'set' . ucfirst($relation['field']);
if ($relation['action'] === 'delete') {
$setter = 'set'.ucfirst($relation['field']);
if ('delete' === $relation['action']) {
$em->remove($record);
} elseif (method_exists($record, $setter)) {
$valueToSet = $relation['type'] === 'object' ? $fallbackUser : $fallbackUser->getId();
$record->$setter($valueToSet);
$valueToSet = 'object' === $relation['type'] ? $fallbackUser : $fallbackUser->getId();
$record->{$setter}($valueToSet);
if (method_exists($record, 'getResourceFile') && $record->getResourceFile()) {
$resourceFile = $record->getResourceFile();
if (!$em->contains($resourceFile)) {
@ -319,7 +321,7 @@ class UserRepository extends ResourceRepository implements PasswordUpgraderInter
$fallbackUser = $this->findOneBy(['status' => User::ROLE_FALLBACK], ['id' => 'ASC']);
if (!$fallbackUser) {
throw new \Exception("User not found.");
throw new Exception('User not found.');
}
return $fallbackUser;

@ -9,9 +9,9 @@ use DateTime;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
#[ORM\Table(name: "c_attendance_result_comment")]
#[ORM\Index(columns: ["attendance_sheet_id"], name: "attendance_sheet_id")]
#[ORM\Index(columns: ["user_id"], name: "user_id")]
#[ORM\Table(name: 'c_attendance_result_comment')]
#[ORM\Index(columns: ['attendance_sheet_id'], name: 'attendance_sheet_id')]
#[ORM\Index(columns: ['user_id'], name: 'user_id')]
class CAttendanceResultComment
{
#[ORM\Column(name: 'iid', type: 'integer')]

Loading…
Cancel
Save