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. 2
      src/CoreBundle/Controller/SocialController.php
  3. 2
      src/CoreBundle/Entity/Language.php
  4. 1
      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. 12
      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;
}
}

@ -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

@ -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;
}
}
@ -295,11 +297,11 @@ class UserRepository extends ResourceRepository implements PasswordUpgraderInter
foreach ($records as $record) {
$setter = 'set'.ucfirst($relation['field']);
if ($relation['action'] === 'delete') {
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