Minor: Format code

pull/4988/head
Angel Fernando Quiroz Campos 1 year ago
parent 0367472c43
commit 2d112da1fe
  1. 6
      src/CoreBundle/Command/UpdateVueTranslations.php
  2. 8
      src/CoreBundle/Controller/Api/CreateSocialPostAttachmentAction.php
  3. 2
      src/CoreBundle/Controller/Api/SocialPostAttachmentsController.php
  4. 4
      src/CoreBundle/Entity/SocialPost.php
  5. 2
      src/CoreBundle/Migrations/Schema/V200/Version20231022124700.php
  6. 4
      src/CoreBundle/Migrations/Schema/V200/Version20231026221100.php
  7. 12
      src/CoreBundle/Migrations/Schema/V200/Version20231026231100.php
  8. 8
      src/CoreBundle/Migrations/Schema/V200/Version20231031204300.php
  9. 2
      src/CoreBundle/State/CategorizedExerciseResultStateProvider.php
  10. 2
      src/CourseBundle/Entity/CLp.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.
*
* <code>
* $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);
}

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

@ -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()]);

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

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

@ -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;');
}
}
}

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

@ -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');
}
}

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

@ -199,8 +199,6 @@ class CLp extends AbstractResource implements ResourceInterface, ResourceShowCou
/**
* Get lpType.
*
* @return int
*/
public function getLpType(): int
{

Loading…
Cancel
Save