From 2d112da1fe01c7b5cdbfc581a4e4f8c827015be6 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Thu, 9 Nov 2023 17:31:58 -0500 Subject: [PATCH] Minor: Format code --- src/CoreBundle/Command/UpdateVueTranslations.php | 6 +++--- .../Api/CreateSocialPostAttachmentAction.php | 8 +++++--- .../Api/SocialPostAttachmentsController.php | 2 -- src/CoreBundle/Entity/SocialPost.php | 4 ++-- .../Migrations/Schema/V200/Version20231022124700.php | 2 +- .../Migrations/Schema/V200/Version20231026221100.php | 4 ++-- .../Migrations/Schema/V200/Version20231026231100.php | 12 ++++++++---- .../Migrations/Schema/V200/Version20231031204300.php | 8 ++++---- .../State/CategorizedExerciseResultStateProvider.php | 2 +- src/CourseBundle/Entity/CLp.php | 2 -- 10 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/CoreBundle/Command/UpdateVueTranslations.php b/src/CoreBundle/Command/UpdateVueTranslations.php index f01b3b081e..8c2ed8b6be 100644 --- a/src/CoreBundle/Command/UpdateVueTranslations.php +++ b/src/CoreBundle/Command/UpdateVueTranslations.php @@ -84,7 +84,7 @@ class UpdateVueTranslations extends Command } /** - * Replace specifiers in a string to allow rendering them by i18n + * Replace specifiers in a string to allow rendering them by i18n. * * * $txt = "Bonjour %s. Je m’appelle %s"; @@ -99,12 +99,12 @@ class UpdateVueTranslations extends Command $type = $matches[1]; return match ($type) { - "s", "d", "f" => "{".$count++."}", + 's', 'd', 'f' => '{'.$count++.'}', default => $matches[0], }; }; - $pattern = "/%([sdf])/"; + $pattern = '/%([sdf])/'; return preg_replace_callback($pattern, $replace, $text); } diff --git a/src/CoreBundle/Controller/Api/CreateSocialPostAttachmentAction.php b/src/CoreBundle/Controller/Api/CreateSocialPostAttachmentAction.php index 66dce03e33..b83b2dd22d 100644 --- a/src/CoreBundle/Controller/Api/CreateSocialPostAttachmentAction.php +++ b/src/CoreBundle/Controller/Api/CreateSocialPostAttachmentAction.php @@ -10,6 +10,8 @@ use Chamilo\CoreBundle\Entity\SocialPost; use Chamilo\CoreBundle\Entity\SocialPostAttachment; use Chamilo\CoreBundle\Entity\User; use Chamilo\CoreBundle\Repository\Node\SocialPostAttachmentRepository; +use DateTime; +use DateTimeZone; use Doctrine\ORM\EntityManager; use Exception; use Symfony\Component\HttpFoundation\File\UploadedFile; @@ -28,12 +30,12 @@ class CreateSocialPostAttachmentAction extends BaseResourceFileAction $socialPostId = $request->request->get('messageId'); if (!$uploadedFile instanceof UploadedFile) { - throw new \Exception('No file uploaded'); + throw new Exception('No file uploaded'); } $socialPost = $em->getRepository(SocialPost::class)->find($socialPostId); if (!$socialPost) { - throw new \Exception('No social post found'); + throw new Exception('No social post found'); } /** @var User $currentUser */ @@ -44,7 +46,7 @@ class CreateSocialPostAttachmentAction extends BaseResourceFileAction $attachment->setFilename($uploadedFile->getClientOriginalName()); $attachment->setSize($uploadedFile->getSize()); $attachment->setInsertUserId($currentUser->getId()); - $attachment->setInsertDateTime(new \DateTime('now', new \DateTimeZone('UTC'))); + $attachment->setInsertDateTime(new DateTime('now', new DateTimeZone('UTC'))); $attachment->setParent($currentUser); $attachment->addUserLink($currentUser); diff --git a/src/CoreBundle/Controller/Api/SocialPostAttachmentsController.php b/src/CoreBundle/Controller/Api/SocialPostAttachmentsController.php index d3f9fc7257..ceaab2e607 100644 --- a/src/CoreBundle/Controller/Api/SocialPostAttachmentsController.php +++ b/src/CoreBundle/Controller/Api/SocialPostAttachmentsController.php @@ -8,13 +8,11 @@ use Chamilo\CoreBundle\Entity\SocialPost; use Chamilo\CoreBundle\Entity\SocialPostAttachment; use Chamilo\CoreBundle\Repository\Node\SocialPostAttachmentRepository; use Doctrine\ORM\EntityManager; -use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Security\Core\Security; class SocialPostAttachmentsController extends BaseResourceFileAction { - public function __invoke(SocialPost $socialPost, EntityManager $em, Security $security, SocialPostAttachmentRepository $attachmentRepo): JsonResponse { $attachments = $em->getRepository(SocialPostAttachment::class)->findBy(['socialPost' => $socialPost->getId()]); diff --git a/src/CoreBundle/Entity/SocialPost.php b/src/CoreBundle/Entity/SocialPost.php index d9161c2a05..d7c435853c 100644 --- a/src/CoreBundle/Entity/SocialPost.php +++ b/src/CoreBundle/Entity/SocialPost.php @@ -147,8 +147,8 @@ class SocialPost #[ORM\OneToMany( targetEntity: SocialPostAttachment::class, - mappedBy: "socialPost", - cascade: ["persist", "remove"], + mappedBy: 'socialPost', + cascade: ['persist', 'remove'], orphanRemoval: true )] private Collection $attachments; diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20231022124700.php b/src/CoreBundle/Migrations/Schema/V200/Version20231022124700.php index e757a7b9b4..43951a4c3e 100644 --- a/src/CoreBundle/Migrations/Schema/V200/Version20231022124700.php +++ b/src/CoreBundle/Migrations/Schema/V200/Version20231022124700.php @@ -453,7 +453,7 @@ final class Version20231022124700 extends AbstractMigrationChamilo // Reconstructing the URL with the new courseId and adjusted parameters. return $matches[1].'?cid='.$courseId.'&sid='.$matches[5].'&gid='.$matches[7].$remainingParams; - // Return the new URL. + // Return the new URL. }, $htmlContent ); diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20231026221100.php b/src/CoreBundle/Migrations/Schema/V200/Version20231026221100.php index 8534a6a025..19ffb20803 100644 --- a/src/CoreBundle/Migrations/Schema/V200/Version20231026221100.php +++ b/src/CoreBundle/Migrations/Schema/V200/Version20231026221100.php @@ -20,8 +20,8 @@ class Version20231026221100 extends AbstractMigrationChamilo { if (false === $schema->hasTable('social_post_attachments')) { $this->addSql("CREATE TABLE social_post_attachments (id INT AUTO_INCREMENT NOT NULL, social_post_id BIGINT DEFAULT NULL, resource_node_id BIGINT DEFAULT NULL, path VARCHAR(255) NOT NULL, filename LONGTEXT NOT NULL, size INT NOT NULL, sys_insert_user_id INT NOT NULL, sys_insert_datetime DATETIME NOT NULL COMMENT '(DC2Type:datetime)', sys_lastedit_user_id INT DEFAULT NULL, sys_lastedit_datetime DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime)', INDEX IDX_DF2A8F34C4F2D6B1 (social_post_id), UNIQUE INDEX UNIQ_DF2A8F341BAD783F (resource_node_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC;"); - $this->addSql("ALTER TABLE social_post_attachments ADD CONSTRAINT FK_DF2A8F34C4F2D6B1 FOREIGN KEY (social_post_id) REFERENCES social_post (id) ON DELETE CASCADE;"); - $this->addSql("ALTER TABLE social_post_attachments ADD CONSTRAINT FK_DF2A8F341BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE;"); + $this->addSql('ALTER TABLE social_post_attachments ADD CONSTRAINT FK_DF2A8F34C4F2D6B1 FOREIGN KEY (social_post_id) REFERENCES social_post (id) ON DELETE CASCADE;'); + $this->addSql('ALTER TABLE social_post_attachments ADD CONSTRAINT FK_DF2A8F341BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE;'); } } } diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20231026231100.php b/src/CoreBundle/Migrations/Schema/V200/Version20231026231100.php index f8f0a7424b..b1f818812e 100644 --- a/src/CoreBundle/Migrations/Schema/V200/Version20231026231100.php +++ b/src/CoreBundle/Migrations/Schema/V200/Version20231026231100.php @@ -11,6 +11,8 @@ use Chamilo\CoreBundle\Entity\SocialPostAttachment; use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo; use Chamilo\CoreBundle\Repository\Node\SocialPostAttachmentRepository; use Chamilo\CoreBundle\Repository\Node\UserRepository; +use DateTime; +use DateTimeZone; use DirectoryIterator; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Schema\Schema; @@ -39,12 +41,14 @@ final class Version20231026231100 extends AbstractMigrationChamilo $sub = $em->createQueryBuilder(); $sub->select('sp.id') - ->from('Chamilo\CoreBundle\Entity\SocialPost', 'sp'); + ->from('Chamilo\CoreBundle\Entity\SocialPost', 'sp') + ; $qb = $em->createQueryBuilder(); $qb->select('ma') ->from('Chamilo\CoreBundle\Entity\MessageAttachment', 'ma') - ->where($qb->expr()->in('ma.message', $sub->getDQL())); + ->where($qb->expr()->in('ma.message', $sub->getDQL())) + ; $query = $qb->getQuery(); $messageAttachments = $query->getResult(); @@ -73,7 +77,7 @@ final class Version20231026231100 extends AbstractMigrationChamilo $attachment->setFilename($uploadFile->getClientOriginalName()); $attachment->setSize($uploadFile->getSize()); $attachment->setInsertUserId($sender->getId()); - $attachment->setInsertDateTime(new \DateTime('now', new \DateTimeZone('UTC'))); + $attachment->setInsertDateTime(new DateTime('now', new DateTimeZone('UTC'))); $attachment->setParent($sender); $attachment->addUserLink($sender); $attachment->setCreator($sender); @@ -102,7 +106,7 @@ final class Version20231026231100 extends AbstractMigrationChamilo if ($fileInfo->isDir()) { $result = $this->findFileRecursively($filePath, $targetFile); - if ($result !== null) { + if (null !== $result) { return $result; } } else { diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20231031204300.php b/src/CoreBundle/Migrations/Schema/V200/Version20231031204300.php index b8c1aef90f..b4fe16659a 100644 --- a/src/CoreBundle/Migrations/Schema/V200/Version20231031204300.php +++ b/src/CoreBundle/Migrations/Schema/V200/Version20231031204300.php @@ -13,13 +13,13 @@ final class Version20231031204300 extends AbstractMigrationChamilo { public function getDescription(): string { - return "Allow message sender to be null"; + return 'Allow message sender to be null'; } public function up(Schema $schema): void { - $this->addSql("ALTER TABLE message DROP FOREIGN KEY FK_B6BD307FF6C43E79"); - $this->addSql("ALTER TABLE message CHANGE user_sender_id user_sender_id INT DEFAULT NULL"); - $this->addSql("ALTER TABLE message ADD CONSTRAINT FK_B6BD307FF6C43E79 FOREIGN KEY (user_sender_id) REFERENCES user (id) ON DELETE SET NULL"); + $this->addSql('ALTER TABLE message DROP FOREIGN KEY FK_B6BD307FF6C43E79'); + $this->addSql('ALTER TABLE message CHANGE user_sender_id user_sender_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE message ADD CONSTRAINT FK_B6BD307FF6C43E79 FOREIGN KEY (user_sender_id) REFERENCES user (id) ON DELETE SET NULL'); } } diff --git a/src/CoreBundle/State/CategorizedExerciseResultStateProvider.php b/src/CoreBundle/State/CategorizedExerciseResultStateProvider.php index 63a7d8cb35..777e9864a4 100644 --- a/src/CoreBundle/State/CategorizedExerciseResultStateProvider.php +++ b/src/CoreBundle/State/CategorizedExerciseResultStateProvider.php @@ -11,7 +11,6 @@ use ApiPlatform\State\ProviderInterface; use Chamilo\CoreBundle\ApiResource\CategorizedExerciseResult; use Chamilo\CoreBundle\Entity\TrackEExercise; use Chamilo\CoreBundle\Security\Authorization\Voter\TrackEExerciseVoter; -use Symfony\Component\Security\Core\Exception\AccessDeniedException; use function count; use Doctrine\ORM\EntityManagerInterface; use Event; @@ -22,6 +21,7 @@ use Question; use QuestionOptionsEvaluationPlugin; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; +use Symfony\Component\Security\Core\Exception\AccessDeniedException; use TestCategory; class CategorizedExerciseResultStateProvider implements ProviderInterface diff --git a/src/CourseBundle/Entity/CLp.php b/src/CourseBundle/Entity/CLp.php index fb08c6fcea..2f5bb470e6 100644 --- a/src/CourseBundle/Entity/CLp.php +++ b/src/CourseBundle/Entity/CLp.php @@ -199,8 +199,6 @@ class CLp extends AbstractResource implements ResourceInterface, ResourceShowCou /** * Get lpType. - * - * @return int */ public function getLpType(): int {