Minor: Format code

pull/5414/head
Angel Fernando Quiroz Campos 7 months ago
parent 37b2df6c7f
commit 769d1766c7
  1. 3
      src/CoreBundle/Controller/SecurityController.php
  2. 6
      src/CoreBundle/DataFixtures/ExtraFieldFixtures.php
  3. 4081
      src/CoreBundle/DataFixtures/SettingsCurrentFixtures.php
  4. 4
      src/CoreBundle/Entity/MailTemplate.php
  5. 2
      src/CoreBundle/Entity/NotificationEventRelUser.php
  6. 22
      src/CoreBundle/Entity/PortfolioCategory.php
  7. 2
      src/CoreBundle/Entity/PortfolioComment.php
  8. 2
      src/CoreBundle/EventListener/CourseListener.php
  9. 2
      src/CoreBundle/Framework/Container.php
  10. 3
      src/CoreBundle/Migrations/Schema/V200/Version20240414120300.php
  11. 9
      src/CoreBundle/Migrations/Schema/V200/Version20240416110300.php
  12. 4
      src/CoreBundle/Repository/TrackELoginRepository.php
  13. 2
      src/CoreBundle/Settings/AbstractSettingsSchema.php
  14. 11
      src/CoreBundle/Settings/SettingsManager.php
  15. 2
      src/CoreBundle/State/CalendarEventStateProvider.php
  16. 2
      src/CoreBundle/State/UserRelUserStateProcessor.php
  17. 4
      src/CoreBundle/State/UserStateProvider.php
  18. 2
      src/CoreBundle/Tool/Exercise.php
  19. 2
      tests/CourseBundle/Repository/CQuizRepositoryTest.php

@ -11,6 +11,7 @@ use Chamilo\CoreBundle\Entity\Legal;
use Chamilo\CoreBundle\Repository\TrackELoginRecordRepository;
use Chamilo\CoreBundle\ServiceHelper\UserHelper;
use Chamilo\CoreBundle\Settings\SettingsManager;
use DateTime;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@ -62,7 +63,7 @@ class SecurityController extends AbstractController
return $this->json(['error' => $message], 401);
}
if (null !== $user->getExpirationDate() && $user->getExpirationDate() <= new \DateTime()) {
if (null !== $user->getExpirationDate() && $user->getExpirationDate() <= new DateTime()) {
$message = $translator->trans('Your account has expired.');
$tokenStorage->setToken(null);

@ -845,7 +845,8 @@ class ExtraFieldFixtures extends Fixture implements FixtureGroupInterface
->setItemType($data['item_type'])
->setValueType($data['value_type'])
->setChangeable($data['changeable'] ?? false)
->setVisibleToSelf($data['visible_to_self'] ?? false);
->setVisibleToSelf($data['visible_to_self'] ?? false)
;
if (isset($data['default_value'])) {
$extraField->setDefaultValue((string) $data['default_value']);
@ -857,7 +858,8 @@ class ExtraFieldFixtures extends Fixture implements FixtureGroupInterface
$extraFieldOption = new ExtraFieldOptions();
$extraFieldOption->setField($extraField)
->setDisplayText($option)
->setOptionOrder(array_search($option, $options) + 1);
->setOptionOrder(array_search($option, $options) + 1)
;
$manager->persist($extraFieldOption);
}

File diff suppressed because it is too large Load Diff

@ -29,11 +29,11 @@ class MailTemplate
#[ORM\Column(name: 'type', type: 'string', nullable: false)]
protected string $type;
#[ORM\ManyToOne(targetEntity: "User")]
#[ORM\ManyToOne(targetEntity: 'User')]
#[ORM\JoinColumn(name: 'author_id', referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
protected ?User $author = null;
#[ORM\ManyToOne(targetEntity: "AccessUrl")]
#[ORM\ManyToOne(targetEntity: 'AccessUrl')]
#[ORM\JoinColumn(name: 'url_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')]
protected ?AccessUrl $url = null;

@ -38,6 +38,7 @@ class NotificationEventRelUser
public function setEvent(NotificationEvent $event): self
{
$this->event = $event;
return $this;
}
@ -49,6 +50,7 @@ class NotificationEventRelUser
public function setUser(User $user): self
{
$this->user = $user;
return $this;
}
}

@ -56,8 +56,6 @@ class PortfolioCategory implements Stringable
/**
* Get id.
*
* @return int|null
*/
public function getId(): ?int
{
@ -66,8 +64,6 @@ class PortfolioCategory implements Stringable
/**
* Get title.
*
* @return string
*/
public function getTitle(): string
{
@ -76,9 +72,6 @@ class PortfolioCategory implements Stringable
/**
* Set title.
*
* @param string $title
* @return PortfolioCategory
*/
public function setTitle(string $title): self
{
@ -94,9 +87,6 @@ class PortfolioCategory implements Stringable
/**
* Set description.
*
* @param string|null $description
* @return PortfolioCategory
*/
public function setDescription(?string $description): self
{
@ -112,9 +102,6 @@ class PortfolioCategory implements Stringable
/**
* Set isVisible.
*
* @param bool $isVisible
* @return PortfolioCategory
*/
public function setIsVisible(bool $isVisible): self
{
@ -125,11 +112,6 @@ class PortfolioCategory implements Stringable
/**
* Get items.
*
* @param Course|null $course
* @param Session|null $session
* @param bool $onlyVisibles
* @return ArrayCollection
*/
public function getItems(?Course $course = null, ?Session $session = null, bool $onlyVisibles = false): ArrayCollection
{
@ -179,7 +161,7 @@ class PortfolioCategory implements Stringable
return $this->children;
}
public function addChild(PortfolioCategory $child): self
public function addChild(self $child): self
{
if (!$this->children->contains($child)) {
$this->children[] = $child;
@ -189,7 +171,7 @@ class PortfolioCategory implements Stringable
return $this;
}
public function removeChild(PortfolioCategory $child): self
public function removeChild(self $child): self
{
if ($this->children->removeElement($child)) {
if ($child->getParent() === $this) {

@ -20,7 +20,7 @@ class PortfolioComment
public const VISIBILITY_VISIBLE = 1;
public const VISIBILITY_PER_USER = 2;
#[ORM\Column(type: 'smallint', options: ["default" => self::VISIBILITY_VISIBLE])]
#[ORM\Column(type: 'smallint', options: ['default' => self::VISIBILITY_VISIBLE])]
protected int $visibility;
#[ORM\Id]

@ -16,6 +16,7 @@ use Chamilo\CoreBundle\Security\Authorization\Voter\GroupVoter;
use Chamilo\CoreBundle\Security\Authorization\Voter\SessionVoter;
use Chamilo\CourseBundle\Controller\CourseControllerInterface;
use Chamilo\CourseBundle\Entity\CGroup;
use ChamiloSession;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Request;
@ -30,7 +31,6 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use Twig\Environment;
use ChamiloSession;
/**
* Class CourseListener.

@ -50,7 +50,6 @@ use Chamilo\CourseBundle\Repository\CCalendarEventAttachmentRepository;
use Chamilo\CourseBundle\Repository\CCalendarEventRepository;
use Chamilo\CourseBundle\Repository\CCourseDescriptionRepository;
use Chamilo\CourseBundle\Repository\CDocumentRepository;
use Chamilo\CourseBundle\Repository\CQuizCategoryRepository;
use Chamilo\CourseBundle\Repository\CForumAttachmentRepository;
use Chamilo\CourseBundle\Repository\CForumCategoryRepository;
use Chamilo\CourseBundle\Repository\CForumPostRepository;
@ -65,6 +64,7 @@ use Chamilo\CourseBundle\Repository\CLpCategoryRepository;
use Chamilo\CourseBundle\Repository\CLpItemRepository;
use Chamilo\CourseBundle\Repository\CLpRepository;
use Chamilo\CourseBundle\Repository\CNotebookRepository;
use Chamilo\CourseBundle\Repository\CQuizCategoryRepository;
use Chamilo\CourseBundle\Repository\CQuizQuestionCategoryRepository;
use Chamilo\CourseBundle\Repository\CQuizQuestionRepository;
use Chamilo\CourseBundle\Repository\CQuizRepository;

@ -6,8 +6,8 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Chamilo\CoreBundle\DataFixtures\SettingsCurrentFixtures;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
class Version20240414120300 extends AbstractMigrationChamilo
@ -56,6 +56,7 @@ class Version20240414120300 extends AbstractMigrationChamilo
$flattenedSettings[] = $setting;
}
}
return $flattenedSettings;
}
}

@ -6,8 +6,9 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Chamilo\CoreBundle\DataFixtures\ExtraFieldFixtures;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use DateTime;
use Doctrine\DBAL\Schema\Schema;
class Version20240416110300 extends AbstractMigrationChamilo
@ -23,14 +24,14 @@ class Version20240416110300 extends AbstractMigrationChamilo
foreach ($extraFields as $field) {
$count = $this->connection->executeQuery(
"SELECT COUNT(*) FROM extra_field WHERE variable = :variable AND item_type = :item_type",
'SELECT COUNT(*) FROM extra_field WHERE variable = :variable AND item_type = :item_type',
[
'variable' => $field['variable'],
'item_type' => $field['item_type'],
]
)->fetchOne();
if ($count == 0) {
if (0 == $count) {
$this->connection->insert('extra_field', [
'item_type' => $field['item_type'],
'value_type' => $field['value_type'],
@ -39,7 +40,7 @@ class Version20240416110300 extends AbstractMigrationChamilo
'visible_to_self' => $field['visible_to_self'] ? 1 : 0,
'changeable' => $field['changeable'] ? 1 : 0,
'filter' => 1,
'created_at' => (new \DateTime())->format('Y-m-d H:i:s'),
'created_at' => (new DateTime())->format('Y-m-d H:i:s'),
]);
}
}

@ -10,8 +10,6 @@ use Chamilo\CoreBundle\Entity\TrackELogin;
use Chamilo\CoreBundle\Entity\User;
use DateTime;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\NoResultException;
use Doctrine\Persistence\ManagerRegistry;
class TrackELoginRepository extends ServiceEntityRepository
@ -41,7 +39,7 @@ class TrackELoginRepository extends ServiceEntityRepository
['loginDate' => 'DESC']
);
if ($lastLoginRecord !== null) {
if (null !== $lastLoginRecord) {
$lastLoginRecord->setLogoutDate($logoutDate);
$this->_em->flush();
}

@ -71,7 +71,7 @@ abstract class AbstractSettingsSchema implements SchemaInterface
$existingHelp = $options['help'] ?? '';
if (!empty($existingHelp)) {
$combinedHelp = $helpFromDb . "<br>" . $existingHelp;
$combinedHelp = $helpFromDb.'<br>'.$existingHelp;
} else {
$combinedHelp = $helpFromDb;
}

@ -24,6 +24,8 @@ use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Validator\ConstraintViolationListInterface;
use Symfony\Component\Validator\Exception\ValidatorException;
use const ARRAY_FILTER_USE_KEY;
/**
* Handles the platform settings.
*/
@ -150,9 +152,9 @@ class SettingsManager implements SettingsManagerInterface
$settings = $this->load($category, $name);
if ($settings->has($name)) {
return $settings->get($name);
} else {
return null;
}
return null;
}
$this->loadAll();
@ -161,11 +163,11 @@ class SettingsManager implements SettingsManagerInterface
$settings = $this->schemaList[$category];
if ($settings->has($name)) {
return $settings->get($name);
} else {
}
error_log("Attempted to access undefined setting '$name' in category '$category'.");
return null;
}
}
throw new InvalidArgumentException(sprintf('Category %s not found', $category));
}
@ -179,6 +181,7 @@ class SettingsManager implements SettingsManagerInterface
$schemaList = $session->get('schemas');
if (!empty($schemaList)) {
$this->schemaList = $schemaList;
return;
}
}

@ -5,10 +5,8 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\State;
use ApiPlatform\Doctrine\Orm\State\CollectionProvider;
use ApiPlatform\Metadata\CollectionOperationInterface;
use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProviderInterface;
use Chamilo\CoreBundle\ApiResource\CalendarEvent;
use Chamilo\CoreBundle\Entity\AccessUrl;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Entity\User;

@ -32,7 +32,7 @@ final class UserRelUserStateProcessor implements ProcessorInterface
$result = $this->persistProcessor->process($data, $operation, $uriVariables, $context);
assert($result instanceof UserRelUser);
\assert($result instanceof UserRelUser);
if ($operation instanceof Put) {
if (UserRelUser::USER_RELATION_TYPE_FRIEND === $data->getRelationType()) {

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\State;
@ -29,7 +31,7 @@ final class UserStateProvider implements ProviderInterface
if ($operation instanceof CollectionOperationInterface) {
$providedUsers = $this->collectionProvider->provide($operation, $uriVariables, $context);
assert($providedUsers instanceof Paginator);
\assert($providedUsers instanceof Paginator);
/** @var User $user */
foreach ($providedUsers as $user) {

@ -6,8 +6,8 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\Tool;
use Chamilo\CourseBundle\Entity\CQuizCategory;
use Chamilo\CourseBundle\Entity\CQuiz;
use Chamilo\CourseBundle\Entity\CQuizCategory;
use Chamilo\CourseBundle\Entity\CQuizQuestion;
use Chamilo\CourseBundle\Entity\CQuizQuestionCategory;

@ -6,8 +6,8 @@ declare(strict_types=1);
namespace Chamilo\Tests\CourseBundle\Repository;
use Chamilo\CourseBundle\Entity\CQuizCategory;
use Chamilo\CourseBundle\Entity\CQuiz;
use Chamilo\CourseBundle\Entity\CQuizCategory;
use Chamilo\CourseBundle\Repository\CQuizRepository;
use Chamilo\Tests\AbstractApiTest;
use Chamilo\Tests\ChamiloTestTrait;

Loading…
Cancel
Save