diff --git a/composer.json b/composer.json index deceba271fa..f09c527d90b 100755 --- a/composer.json +++ b/composer.json @@ -65,7 +65,7 @@ "ext-zip": "*", "ext-zlib": "*", "a2lix/translation-form-bundle": "^3.0", - "api-platform/core": "^2.7", + "api-platform/core": "^3.0", "beberlei/doctrineextensions": "^1.3", "chamilo/google-map-form-type-bundle": "1.7", "chamilo/settings-bundle": "1.3.0", diff --git a/composer.lock b/composer.lock index d13960d409e..ac0df38ba7c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,24 +4,24 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "905a7323ab6930165be1edc8e85902a1", + "content-hash": "00010bf1a816a35566eca50c4b860de4", "packages": [ { "name": "a2lix/auto-form-bundle", - "version": "0.4.7", + "version": "0.4.8", "source": { "type": "git", "url": "https://github.com/a2lix/AutoFormBundle.git", - "reference": "0c2f5418ccee0a84edfde18f09a3063fa8664c37" + "reference": "2f954ec9086e11eac559ff5aab843a39dcf4326c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/a2lix/AutoFormBundle/zipball/0c2f5418ccee0a84edfde18f09a3063fa8664c37", - "reference": "0c2f5418ccee0a84edfde18f09a3063fa8664c37", + "url": "https://api.github.com/repos/a2lix/AutoFormBundle/zipball/2f954ec9086e11eac559ff5aab843a39dcf4326c", + "reference": "2f954ec9086e11eac559ff5aab843a39dcf4326c", "shasum": "" }, "require": { - "doctrine/persistence": "^2.0|^3.0", + "doctrine/persistence": "^2.0|^3.0|^4.0", "php": "^8.1", "symfony/config": "^5.4.30|^6.3|^7.0", "symfony/dependency-injection": "^5.4.30|^6.3|^7.0", @@ -30,7 +30,7 @@ "symfony/http-kernel": "^5.4.30|^6.3|^7.0" }, "require-dev": { - "doctrine/orm": "^2.15", + "doctrine/orm": "^2.15|^3.0", "friendsofphp/php-cs-fixer": "^3.45", "kubawerlos/php-cs-fixer-custom-fixers": "^3.18", "phpstan/phpstan": "^1.10", @@ -81,9 +81,9 @@ ], "support": { "issues": "https://github.com/a2lix/AutoFormBundle/issues", - "source": "https://github.com/a2lix/AutoFormBundle/tree/0.4.7" + "source": "https://github.com/a2lix/AutoFormBundle/tree/0.4.8" }, - "time": "2024-01-09T18:21:56+00:00" + "time": "2025-04-08T09:01:34+00:00" }, { "name": "a2lix/translation-form-bundle", @@ -174,107 +174,157 @@ }, { "name": "api-platform/core", - "version": "v2.7.18", + "version": "v3.4.17", "source": { "type": "git", "url": "https://github.com/api-platform/core.git", - "reference": "6ff3e05d97602cdaa3b329112ca21f7e916a504d" + "reference": "c5fb664d17ed9ae919394514ea69a5039d2ad9ab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/api-platform/core/zipball/6ff3e05d97602cdaa3b329112ca21f7e916a504d", - "reference": "6ff3e05d97602cdaa3b329112ca21f7e916a504d", + "url": "https://api.github.com/repos/api-platform/core/zipball/c5fb664d17ed9ae919394514ea69a5039d2ad9ab", + "reference": "c5fb664d17ed9ae919394514ea69a5039d2ad9ab", "shasum": "" }, "require": { "doctrine/inflector": "^1.0 || ^2.0", - "php": ">=7.1", + "php": ">=8.1", "psr/cache": "^1.0 || ^2.0 || ^3.0", "psr/container": "^1.0 || ^2.0", - "symfony/deprecation-contracts": "^2.1 || ^3.0", - "symfony/http-foundation": "^4.4 || ^5.1 || ^6.0", - "symfony/http-kernel": "^4.4 || ^5.1 || ^6.0", - "symfony/property-access": "^3.4.19 || ^4.4 || ^5.1 || ^6.0", - "symfony/property-info": "^3.4 || ^4.4 || ^5.2.1 || ^6.0", - "symfony/serializer": "^4.4 || ^5.1 || ^6.0", - "symfony/web-link": "^4.4 || ^5.1 || ^6.0", - "willdurand/negotiation": "^2.0.3 || ^3.0" + "symfony/deprecation-contracts": "^3.1", + "symfony/http-foundation": "^6.4 || ^7.1", + "symfony/http-kernel": "^6.4 || ^7.1", + "symfony/property-access": "^6.4 || ^7.1", + "symfony/property-info": "^6.4 || ^7.1", + "symfony/serializer": "^6.4 || ^7.1", + "symfony/translation-contracts": "^3.3", + "symfony/web-link": "^6.4 || ^7.1", + "willdurand/negotiation": "^3.0" }, "conflict": { - "doctrine/common": "<2.7", + "doctrine/common": "<3.2.2", "doctrine/dbal": "<2.10", - "doctrine/mongodb-odm": "<2.2", + "doctrine/mongodb-odm": "<2.4", + "doctrine/orm": "<2.14.0", "doctrine/persistence": "<1.3", - "elasticsearch/elasticsearch": ">=8.0" + "elasticsearch/elasticsearch": ">=8.0,<8.4", + "phpspec/prophecy": "<1.15", + "phpunit/phpunit": "<9.5", + "symfony/framework-bundle": "6.4.6 || 7.0.6", + "symfony/var-exporter": "<6.1.1" + }, + "replace": { + "api-platform/doctrine-common": "self.version", + "api-platform/doctrine-odm": "self.version", + "api-platform/doctrine-orm": "self.version", + "api-platform/documentation": "self.version", + "api-platform/elasticsearch": "self.version", + "api-platform/graphql": "self.version", + "api-platform/http-cache": "self.version", + "api-platform/hydra": "self.version", + "api-platform/json-api": "self.version", + "api-platform/json-hal": "self.version", + "api-platform/json-schema": "self.version", + "api-platform/jsonld": "self.version", + "api-platform/laravel": "self.version", + "api-platform/metadata": "self.version", + "api-platform/openapi": "self.version", + "api-platform/parameter-validator": "self.version", + "api-platform/ramsey-uuid": "self.version", + "api-platform/serializer": "self.version", + "api-platform/state": "self.version", + "api-platform/symfony": "self.version", + "api-platform/validator": "self.version" }, "require-dev": { - "behat/behat": "^3.1", - "behat/mink": "^1.9@dev", - "doctrine/annotations": "^1.7", + "api-platform/doctrine-common": "^3.4 || ^4.0", + "api-platform/doctrine-odm": "^3.4 || ^4.0", + "api-platform/doctrine-orm": "^3.4 || ^4.0", + "api-platform/documentation": "^3.4 || ^4.0", + "api-platform/elasticsearch": "^3.4 || ^4.0", + "api-platform/graphql": "^3.4 || ^4.0", + "api-platform/http-cache": "^3.4 || ^4.0", + "api-platform/hydra": "^3.4 || ^4.0", + "api-platform/json-api": "^3.3 || ^4.0", + "api-platform/json-schema": "^3.4 || ^4.0", + "api-platform/jsonld": "^3.4 || ^4.0", + "api-platform/metadata": "^3.4 || ^4.0", + "api-platform/openapi": "^3.4 || ^4.0", + "api-platform/parameter-validator": "^3.4", + "api-platform/ramsey-uuid": "^3.4 || ^4.0", + "api-platform/serializer": "^3.4 || ^4.0", + "api-platform/state": "^3.4 || ^4.0", + "api-platform/validator": "^3.4 || ^4.0", + "behat/behat": "^3.11", + "behat/mink": "^1.9", "doctrine/cache": "^1.11 || ^2.1", - "doctrine/common": "^2.11 || ^3.0", - "doctrine/data-fixtures": "^1.2.2", - "doctrine/dbal": "^2.6 || ^3.0", + "doctrine/common": "^3.2.2", + "doctrine/dbal": "^3.4.0 || ^4.0", "doctrine/doctrine-bundle": "^1.12 || ^2.0", "doctrine/mongodb-odm": "^2.2", - "doctrine/mongodb-odm-bundle": "^4.0", - "doctrine/orm": "^2.6.4", - "elasticsearch/elasticsearch": "^7.11.0", + "doctrine/mongodb-odm-bundle": "^4.0 || ^5.0", + "doctrine/orm": "^2.14 || ^3.0", + "elasticsearch/elasticsearch": "^7.11 || ^8.4", "friends-of-behat/mink-browserkit-driver": "^1.3.1", "friends-of-behat/mink-extension": "^2.2", "friends-of-behat/symfony-extension": "^2.1", - "guzzlehttp/guzzle": "^6.0 || ^7.0", + "guzzlehttp/guzzle": "^6.0 || ^7.1", "jangregor/phpstan-prophecy": "^1.0", "justinrainbow/json-schema": "^5.2.1", - "phpdocumentor/reflection-docblock": "^3.0 || ^4.0 || ^5.1", - "phpdocumentor/type-resolver": "^0.3 || ^0.4 || ^1.4", - "phpspec/prophecy": "^1.10", + "phpspec/prophecy-phpunit": "^2.0", "phpstan/extension-installer": "^1.1", - "phpstan/phpstan": "^1.1", + "phpstan/phpdoc-parser": "^1.13|^2.0", + "phpstan/phpstan": "^1.10", "phpstan/phpstan-doctrine": "^1.0", "phpstan/phpstan-phpunit": "^1.0", "phpstan/phpstan-symfony": "^1.0", + "phpunit/phpunit": "^9.6", "psr/log": "^1.0 || ^2.0 || ^3.0", - "ramsey/uuid": "^3.7 || ^4.0", - "ramsey/uuid-doctrine": "^1.4", - "soyuka/contexts": "^3.3.6", + "ramsey/uuid": "^3.9.7 || ^4.0", + "ramsey/uuid-doctrine": "^1.4 || ^2.0 || ^3.0", + "sebastian/comparator": "<5.0", + "soyuka/contexts": "v3.3.9", + "soyuka/pmu": "^0.0.12", "soyuka/stubs-mongodb": "^1.0", - "symfony/asset": "^3.4 || ^4.4 || ^5.1 || ^6.0", - "symfony/browser-kit": "^4.4 || ^5.1 || ^6.0", - "symfony/cache": "^3.4 || ^4.4 || ^5.1 || ^6.0", - "symfony/config": "^3.4 || ^4.4 || ^5.1 || ^6.0", - "symfony/console": "^3.4 || ^4.4 || ^5.1 || ^6.0", - "symfony/css-selector": "^3.4 || ^4.4 || ^5.1 || ^6.0", - "symfony/debug": "^3.4 || ^4.4 || ^5.1 || ^6.0", - "symfony/dependency-injection": "^3.4 || ^4.4 || ^5.1 || ^6.0", - "symfony/doctrine-bridge": "^3.4 || ^4.4 || ^5.1 || ^6.0", - "symfony/dom-crawler": "^3.4 || ^4.4 || ^5.1 || ^6.0", - "symfony/event-dispatcher": "^3.4 || ^4.4 || ^5.1 || ^6.0", - "symfony/expression-language": "^3.4 || ^4.4 || ^5.1 || ^6.0", - "symfony/finder": "^3.4 || ^4.4 || ^5.1 || ^6.0", - "symfony/form": "^3.4 || ^4.4 || ^5.1 || ^6.0", - "symfony/framework-bundle": "^4.4 || ^5.1 || ^6.0", - "symfony/http-client": "^4.4 || ^5.1 || ^6.0", - "symfony/intl": "^4.4 || ^5.3 || ^6.0", + "symfony/asset": "^6.4 || ^7.1", + "symfony/browser-kit": "^6.4 || ^7.1", + "symfony/cache": "^6.4 || ^7.1", + "symfony/config": "^6.4 || ^7.1", + "symfony/console": "^6.4 || ^7.1", + "symfony/css-selector": "^6.4 || ^7.1", + "symfony/dependency-injection": "^6.4 || ^7.1", + "symfony/doctrine-bridge": "^6.4 || ^7.1", + "symfony/dom-crawler": "^6.4 || ^7.1", + "symfony/error-handler": "^6.4 || ^7.1", + "symfony/event-dispatcher": "^6.4 || ^7.1", + "symfony/expression-language": "^6.4 || ^7.1", + "symfony/finder": "^6.4 || ^7.1", + "symfony/form": "^6.4 || ^7.1", + "symfony/framework-bundle": "^6.4 || ^7.1", + "symfony/http-client": "^6.4 || ^7.1", + "symfony/intl": "^6.4 || ^7.1", "symfony/maker-bundle": "^1.24", "symfony/mercure-bundle": "*", - "symfony/messenger": "^4.4 || ^5.1 || ^6.0", - "symfony/phpunit-bridge": "^5.4 || ^6.0", - "symfony/routing": "^3.4 || ^4.4 || ^5.1 || ^6.0", - "symfony/security-bundle": "^3.4 || ^4.4 || ^5.1 || ^6.0", - "symfony/security-core": "^4.4 || ^5.1 || ^6.0", - "symfony/twig-bundle": "^3.4 || ^4.4 || ^5.1 || ^6.0", - "symfony/validator": "^3.4 || ^4.4 || ^5.1 || ^6.0", - "symfony/web-profiler-bundle": "^4.4 || ^5.1 || ^6.0", - "symfony/yaml": "^3.4 || ^4.4 || ^5.1 || ^6.0", + "symfony/messenger": "^6.4 || ^7.1", + "symfony/phpunit-bridge": "^6.4.1 || ^7.1", + "symfony/routing": "^6.4 || ^7.1", + "symfony/security-bundle": "^6.4 || ^7.1", + "symfony/security-core": "^6.4 || ^7.1", + "symfony/stopwatch": "^6.4 || ^7.1", + "symfony/string": "^6.4 || ^7.1", + "symfony/twig-bundle": "^6.4 || ^7.1", + "symfony/uid": "^6.4 || ^7.1", + "symfony/validator": "^6.4 || ^7.1", + "symfony/web-profiler-bundle": "^6.4 || ^7.1", + "symfony/yaml": "^6.4 || ^7.1", "twig/twig": "^1.42.3 || ^2.12 || ^3.0", - "webonyx/graphql-php": "^14.0" + "webonyx/graphql-php": "^14.0 || ^15.0" }, "suggest": { "doctrine/mongodb-odm-bundle": "To support MongoDB. Only versions 4.0 and later are supported.", "elasticsearch/elasticsearch": "To support Elasticsearch.", "ocramius/package-versions": "To display the API Platform's version in the debug bar.", - "phpdocumentor/reflection-docblock": "To support extracting metadata from PHPDoc.", + "phpstan/phpdoc-parser": "To support extracting metadata from PHPDoc.", "psr/cache-implementation": "To use metadata caching.", "ramsey/uuid": "To support Ramsey's UUID identifiers.", "symfony/cache": "To have metadata caching when using Symfony integration.", @@ -290,17 +340,25 @@ }, "type": "library", "extra": { + "pmu": { + "projects": [ + "./src/*/composer.json", + "src/Doctrine/*/composer.json" + ] + }, + "thanks": { + "url": "https://github.com/api-platform/api-platform", + "name": "api-platform/api-platform" + }, "symfony": { - "require": "^3.4 || ^4.4 || ^5.1 || ^6.0" + "require": "^6.4 || ^7.1" }, "branch-alias": { - "dev-main": "2.7.x-dev" + "dev-3.4": "3.4.x-dev", + "dev-main": "4.0.x-dev" } }, "autoload": { - "files": [ - "src/deprecation.php" - ], "psr-4": { "ApiPlatform\\": "src/" } @@ -331,9 +389,9 @@ ], "support": { "issues": "https://github.com/api-platform/core/issues", - "source": "https://github.com/api-platform/core/tree/v2.7.18" + "source": "https://github.com/api-platform/core/tree/v3.4.17" }, - "time": "2024-03-19T07:17:43+00:00" + "time": "2025-04-07T08:40:57+00:00" }, { "name": "aws/aws-crt-php", @@ -1793,26 +1851,29 @@ }, { "name": "doctrine/deprecations", - "version": "1.1.4", + "version": "1.1.5", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "31610dbb31faa98e6b5447b62340826f54fbc4e9" + "reference": "459c2f5dd3d6a4633d3b5f46ee2b1c40f57d3f38" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/31610dbb31faa98e6b5447b62340826f54fbc4e9", - "reference": "31610dbb31faa98e6b5447b62340826f54fbc4e9", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/459c2f5dd3d6a4633d3b5f46ee2b1c40f57d3f38", + "reference": "459c2f5dd3d6a4633d3b5f46ee2b1c40f57d3f38", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, + "conflict": { + "phpunit/phpunit": "<=7.5 || >=13" + }, "require-dev": { - "doctrine/coding-standard": "^9 || ^12", - "phpstan/phpstan": "1.4.10 || 2.0.3", + "doctrine/coding-standard": "^9 || ^12 || ^13", + "phpstan/phpstan": "1.4.10 || 2.1.11", "phpstan/phpstan-phpunit": "^1.0 || ^2", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.6 || ^10.5 || ^11.5 || ^12", "psr/log": "^1 || ^2 || ^3" }, "suggest": { @@ -1832,9 +1893,9 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/1.1.4" + "source": "https://github.com/doctrine/deprecations/tree/1.1.5" }, - "time": "2024-12-07T21:18:45+00:00" + "time": "2025-04-07T20:06:18+00:00" }, { "name": "doctrine/doctrine-bundle", @@ -3476,16 +3537,16 @@ }, { "name": "gedmo/doctrine-extensions", - "version": "v3.19.0", + "version": "v3.20.0", "source": { "type": "git", "url": "https://github.com/doctrine-extensions/DoctrineExtensions.git", - "reference": "5b0b8a442d19e6701ae64535dc08f7944e2895d2" + "reference": "ea1d37586b8e4bae2a815feb38b177894b12c44c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine-extensions/DoctrineExtensions/zipball/5b0b8a442d19e6701ae64535dc08f7944e2895d2", - "reference": "5b0b8a442d19e6701ae64535dc08f7944e2895d2", + "url": "https://api.github.com/repos/doctrine-extensions/DoctrineExtensions/zipball/ea1d37586b8e4bae2a815feb38b177894b12c44c", + "reference": "ea1d37586b8e4bae2a815feb38b177894b12c44c", "shasum": "" }, "require": { @@ -3580,10 +3641,9 @@ "uploadable" ], "support": { - "email": "gediminas.morkevicius@gmail.com", + "docs": "https://github.com/doctrine-extensions/DoctrineExtensions/tree/main/doc", "issues": "https://github.com/doctrine-extensions/DoctrineExtensions/issues", - "source": "https://github.com/doctrine-extensions/DoctrineExtensions/tree/v3.19.0", - "wiki": "https://github.com/Atlantic18/DoctrineExtensions/tree/main/doc" + "source": "https://github.com/doctrine-extensions/DoctrineExtensions/tree/v3.20.0" }, "funding": [ { @@ -3603,7 +3663,7 @@ "type": "github" } ], - "time": "2025-02-24T22:12:57+00:00" + "time": "2025-04-04T17:19:27+00:00" }, { "name": "google/auth", @@ -4767,16 +4827,16 @@ }, { "name": "jbroadway/urlify", - "version": "1.2.4-stable", + "version": "1.2.5-stable", "source": { "type": "git", "url": "https://github.com/jbroadway/urlify.git", - "reference": "d0fafbaa1dc14e8039cdf5c72a932a8d1de1750e" + "reference": "62f75cfa5ec06935091b348cac52c6672a7ca1f4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/jbroadway/urlify/zipball/d0fafbaa1dc14e8039cdf5c72a932a8d1de1750e", - "reference": "d0fafbaa1dc14e8039cdf5c72a932a8d1de1750e", + "url": "https://api.github.com/repos/jbroadway/urlify/zipball/62f75cfa5ec06935091b348cac52c6672a7ca1f4", + "reference": "62f75cfa5ec06935091b348cac52c6672a7ca1f4", "shasum": "" }, "require": { @@ -4832,9 +4892,9 @@ ], "support": { "issues": "https://github.com/jbroadway/urlify/issues", - "source": "https://github.com/jbroadway/urlify/tree/1.2.4-stable" + "source": "https://github.com/jbroadway/urlify/tree/1.2.5-stable" }, - "time": "2022-06-15T16:46:46+00:00" + "time": "2025-04-01T21:08:37+00:00" }, { "name": "jeroendesloovere/vcard", @@ -21163,16 +21223,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.12.0", + "version": "3.12.1", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "2d1b63db139c3c6ea0c927698e5160f8b3b8d630" + "reference": "ea16a1f3719783345febd3aab41beb55c8c84bfd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/2d1b63db139c3c6ea0c927698e5160f8b3b8d630", - "reference": "2d1b63db139c3c6ea0c927698e5160f8b3b8d630", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/ea16a1f3719783345febd3aab41beb55c8c84bfd", + "reference": "ea16a1f3719783345febd3aab41beb55c8c84bfd", "shasum": "" }, "require": { @@ -21243,7 +21303,7 @@ "type": "thanks_dev" } ], - "time": "2025-03-18T05:04:51+00:00" + "time": "2025-04-04T12:57:55+00:00" }, { "name": "symfony/browser-kit", diff --git a/config/bundles.php b/config/bundles.php index 174031b91a4..b43bf7c0a9e 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -24,7 +24,7 @@ Cocur\Slugify\Bridge\Symfony\CocurSlugifyBundle::class => ['all' => true], KnpU\OAuth2ClientBundle\KnpUOAuth2ClientBundle::class => ['all' => true], Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true], - ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true], + ApiPlatform\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true], Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true], Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true], SymfonyCasts\Bundle\ResetPassword\SymfonyCastsResetPasswordBundle::class => ['all' => true], diff --git a/config/packages/api_platform.yaml b/config/packages/api_platform.yaml index b2d8d18f37a..5e7b82559d7 100644 --- a/config/packages/api_platform.yaml +++ b/config/packages/api_platform.yaml @@ -48,8 +48,6 @@ api_platform: Doctrine\ORM\OptimisticLockException: 409 Doctrine\DBAL\Exception\UniqueConstraintViolationException: 409 - metadata_backward_compatibility_layer: false - # mercure: # hub_url: '%env(MERCURE_SUBSCRIBE_URL)%' diff --git a/public/plugin/H5pImport/Entity/H5pImport.php b/public/plugin/H5pImport/Entity/H5pImport.php index 24238cbbacd..635e26d405f 100644 --- a/public/plugin/H5pImport/Entity/H5pImport.php +++ b/public/plugin/H5pImport/Entity/H5pImport.php @@ -1,6 +1,8 @@ - * - * @ORM\ManyToMany(targetEntity="H5pImportLibrary", mappedBy="h5pImports", cascade={"persist"}) */ - private $libraries; + #[ORM\ManyToMany(targetEntity: H5pImportLibrary::class, mappedBy: 'h5pImports', cascade: ['persist'])] + private Collection $libraries; - /** - * @var H5pImportLibrary - * - * @ORM\ManyToOne(targetEntity="H5pImportLibrary") - * - * @ORM\JoinColumn(name="main_library_id", referencedColumnName="iid", onDelete="SET NULL") - */ - private $mainLibrary; + #[ORM\ManyToOne(targetEntity: H5pImportLibrary::class)] + #[ORM\JoinColumn(name: 'main_library_id', referencedColumnName: 'iid', onDelete: 'SET NULL')] + private H5pImportLibrary $mainLibrary; public function __construct() { diff --git a/public/plugin/H5pImport/Entity/H5pImportLibrary.php b/public/plugin/H5pImport/Entity/H5pImportLibrary.php index d207e7bbb0b..9bf270712d0 100644 --- a/public/plugin/H5pImport/Entity/H5pImportLibrary.php +++ b/public/plugin/H5pImport/Entity/H5pImportLibrary.php @@ -1,6 +1,8 @@ - * - * @ORM\ManyToMany(targetEntity="H5pImport", inversedBy="libraries") - * - * @ORM\JoinTable( - * name="plugin_h5p_import_rel_libraries", - * joinColumns={@ORM\JoinColumn(name="h5p_import_library_id", referencedColumnName="iid", onDelete="CASCADE")}, - * inverseJoinColumns={@ORM\JoinColumn(name="h5p_import_id", referencedColumnName="iid", onDelete="CASCADE")} - * ) - */ - private $h5pImports; - - /** - * @var Course - * - * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course") - * - * @ORM\JoinColumn(name="c_id", referencedColumnName="id", nullable=false) */ - private $course; + #[ORM\ManyToMany(targetEntity: H5pImport::class, inversedBy: 'libraries')] + #[ORM\JoinTable(name: 'plugin_h5p_import_rel_libraries')] + #[ORM\JoinColumn(name: 'h5p_import_library_id', referencedColumnName: 'iid', onDelete: 'CASCADE')] + #[ORM\InverseJoinColumn(name: 'h5p_import_id', referencedColumnName: 'iid', onDelete: 'CASCADE')] + private Collection $h5pImports; + + #[ORM\ManyToOne(targetEntity: Course::class)] + #[ORM\JoinColumn(name: 'c_id', referencedColumnName: 'id', nullable: false)] + private Course $course; public function __construct() { diff --git a/public/plugin/H5pImport/Entity/H5pImportResults.php b/public/plugin/H5pImport/Entity/H5pImportResults.php index 2251915e884..2c6266db262 100644 --- a/public/plugin/H5pImport/Entity/H5pImportResults.php +++ b/public/plugin/H5pImport/Entity/H5pImportResults.php @@ -1,125 +1,67 @@ 'DESC'])] + private Collection $children; - /** - * @var int - * @Gedmo\TreeLeft - * @ORM\Column(name="lft", type="integer", nullable=true, unique=false) - */ - private $lft; + #[Gedmo\TreeLeft] + #[ORM\Column(name: 'lft', type: 'integer', unique: false, nullable: true)] + private ?int $lft; - /** - * @var int - * @Gedmo\TreeRight - * @ORM\Column(name="rgt", type="integer", nullable=true, unique=false) - */ - private $rgt; + #[Gedmo\TreeRight] + #[ORM\Column(name: 'rgt', type: 'integer', unique: false, nullable: true)] + private ?int $rgt; - /** - * @var int - * @Gedmo\TreeLevel - * @ORM\Column(name="lvl", type="integer", nullable=true, unique=false) - */ - private $lvl; + #[Gedmo\TreeLevel] + #[ORM\Column(name: 'lvl', type: 'integer', unique: false, nullable: true)] + private ?int $lvl; - /** - * @var int - * @Gedmo\TreeRoot - * @ORM\Column(name="root", type="integer", nullable=true, unique=false) - */ - private $root; + #[Gedmo\TreeRoot] + #[ORM\Column(name: 'root', type: 'integer', unique: false, nullable: true)] + private ?int $root; /** * Project constructor. @@ -147,258 +92,173 @@ public function __construct() $this->attachment = ''; } - /** - * @return int - */ - public function getId() + public function getId(): ?int { return $this->id; } - /** - * @param int $id - * - * @return $this - */ - public function setId($id) + public function setId(int $id): static { $this->id = $id; return $this; } - /** - * @return string - */ - public function getTitle() + public function getTitle(): string { return $this->title; } - /** - * @param string $title - * - * @return CarePost - */ - public function setTitle($title) + public function setTitle($title): static { $this->title = $title; return $this; } - /** - * @return string - */ - public function getContent() + public function getContent(): string { return $this->content; } - /** - * @param string $content - * - * @return CarePost - */ - public function setContent($content) + public function setContent(string $content): static { $this->content = $content; return $this; } - /** - * @return string - */ - public function getExternalCareId() + public function getExternalCareId(): ?string { return $this->externalCareId; } - /** - * @param string $externalCareId - * - * @return CarePost - */ - public function setExternalCareId($externalCareId) + public function setExternalCareId(?string $externalCareId): static { $this->externalCareId = $externalCareId; return $this; } - public function getUser() + public function getUser(): User { return $this->user; } - /** - * @return CarePost - */ - public function setUser($user) + public function setUser($user): static { $this->user = $user; return $this; } - /** - * @return bool - */ - public function isPrivate() + public function isPrivate(): bool { return $this->private; } - /** - * @param bool $private - * - * @return CarePost - */ - public function setPrivate($private) + public function setPrivate(bool $private): static { $this->private = $private; return $this; } - /** - * @return bool - */ - public function isExternalSource() + public function isExternalSource(): bool { return $this->externalSource; } - /** - * @param bool $externalSource - * - * @return CarePost - */ - public function setExternalSource($externalSource) + public function setExternalSource(bool $externalSource): static { $this->externalSource = $externalSource; return $this; } - /** - * @return string - */ - public function getAttachment() + public function getAttachment(): string { return $this->attachment; } - /** - * @param string $attachment - * - * @return CarePost - */ - public function setAttachment($attachment) + public function setAttachment(string $attachment): static { $this->attachment = $attachment; return $this; } - public function getParent() + public function getParent(): CarePost { return $this->parent; } - /** - * @return CarePost - */ - public function setParent($parent) + public function setParent(CarePost $parent): static { $this->parent = $parent; return $this; } - /** - * @return int - */ - public function hasParent() + public function hasParent(): int { return !empty($this->parent) ? 1 : 0; } - public function getChildren() + public function getChildren(): Collection { return $this->children; } - /** - * @return CarePost - */ - public function setChildren($children) + public function setChildren(Collection $children): static { $this->children = $children; return $this; } - public function getCreatedAt() + public function getCreatedAt(): ?DateTime { return $this->createdAt; } - /** - * @return CarePost - */ - public function setCreatedAt($createdAt) + public function setCreatedAt(?DateTime $createdAt): static { $this->createdAt = $createdAt; return $this; } - public function getUpdatedAt() + public function getUpdatedAt(): ?DateTime { return $this->updatedAt; } - /** - * @return CarePost - */ - public function setUpdatedAt($updatedAt) + public function setUpdatedAt(?DateTime $updatedAt): static { $this->updatedAt = $updatedAt; return $this; } - /** - * @return array - */ - public function getTags() + public function getTags(): array { return $this->tags; } - /** - * @param array $tags - * - * @return CarePost - */ - public function setTags($tags) + public function setTags(array $tags): static { $this->tags = $tags; return $this; } - public function getInsertUser() + public function getInsertUser(): User { return $this->insertUser; } - /** - * @return CarePost - */ - public function setInsertUser($insertUser) + public function setInsertUser(User $insertUser): static { $this->insertUser = $insertUser; diff --git a/src/CoreBundle/DataTransformer/CalendarEventTransformer.php b/src/CoreBundle/DataTransformer/CalendarEventTransformer.php index eac5b309dbf..656d1239523 100644 --- a/src/CoreBundle/DataTransformer/CalendarEventTransformer.php +++ b/src/CoreBundle/DataTransformer/CalendarEventTransformer.php @@ -6,7 +6,6 @@ namespace Chamilo\CoreBundle\DataTransformer; -use ApiPlatform\Core\DataTransformer\DataTransformerInterface; use Chamilo\CoreBundle\ApiResource\CalendarEvent; use Chamilo\CoreBundle\Entity\AgendaReminder; use Chamilo\CoreBundle\Entity\Session; @@ -14,20 +13,18 @@ use Chamilo\CoreBundle\Repository\Node\UsergroupRepository; use Chamilo\CoreBundle\Settings\SettingsManager; use Chamilo\CourseBundle\Entity\CCalendarEvent; -use Chamilo\CourseBundle\Repository\CCalendarEventRepository; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\RouterInterface; -class CalendarEventTransformer implements DataTransformerInterface +readonly class CalendarEventTransformer { public function __construct( - private readonly RouterInterface $router, - private readonly UsergroupRepository $usergroupRepository, - private readonly CCalendarEventRepository $calendarEventRepository, - private readonly SettingsManager $settingsManager, + private RouterInterface $router, + private UsergroupRepository $usergroupRepository, + private SettingsManager $settingsManager, ) {} - public function transform($object, string $to, array $context = []): object + public function transform(CCalendarEvent|Session $object): object { if ($object instanceof Session) { return $this->mapSessionToDto($object); @@ -36,15 +33,8 @@ public function transform($object, string $to, array $context = []): object return $this->mapCCalendarToDto($object); } - public function supportsTransformation($data, string $to, array $context = []): bool + private function mapCCalendarToDto(CCalendarEvent $object): CalendarEvent { - return ($data instanceof CCalendarEvent || $data instanceof Session) && CalendarEvent::class === $to; - } - - private function mapCCalendarToDto(object $object): CalendarEvent - { - \assert($object instanceof CCalendarEvent); - $object->setResourceLinkListFromEntity(); $subscriptionItemTitle = null; @@ -86,11 +76,10 @@ private function mapCCalendarToDto(object $object): CalendarEvent return $calendarEvent; } - private function mapSessionToDto(object $object): CalendarEvent + private function mapSessionToDto(Session $object): CalendarEvent { - \assert($object instanceof Session); - $course = null; + /** @var ?SessionRelCourse $sessionRelCourse */ if ($object->getCourses()->first() instanceof SessionRelCourse) { $course = $object->getCourses()->first()->getCourse(); diff --git a/src/CoreBundle/DataTransformer/CourseToolDataTranformer.php b/src/CoreBundle/DataTransformer/CourseToolDataTranformer.php index b354bb586c3..d6a45b87b98 100644 --- a/src/CoreBundle/DataTransformer/CourseToolDataTranformer.php +++ b/src/CoreBundle/DataTransformer/CourseToolDataTranformer.php @@ -6,7 +6,6 @@ namespace Chamilo\CoreBundle\DataTransformer; -use ApiPlatform\Core\DataTransformer\DataTransformerInterface; use Chamilo\CoreBundle\ApiResource\CourseTool; use Chamilo\CoreBundle\Entity\Course; use Chamilo\CoreBundle\Tool\AbstractTool; @@ -16,7 +15,7 @@ use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\HttpFoundation\RequestStack; -class CourseToolDataTranformer implements DataTransformerInterface +class CourseToolDataTranformer { use CourseFromRequestTrait; @@ -26,10 +25,8 @@ public function __construct( protected readonly ToolChain $toolChain, ) {} - public function transform($object, string $to, array $context = []): object + public function transform(CTool $object): CourseTool { - \assert($object instanceof CTool); - $tool = $object->getTool(); $toolModel = $this->toolChain->getToolFromName( @@ -66,9 +63,4 @@ private function generateToolUrl(AbstractTool $tool, Course $course): string 'gid' => 0, ]); } - - public function supportsTransformation($data, string $to, array $context = []): bool - { - return $data instanceof CTool && CourseTool::class === $to; - } } diff --git a/src/CoreBundle/DataTransformer/SkillTreeNodeTransformer.php b/src/CoreBundle/DataTransformer/SkillTreeNodeTransformer.php index c8e0eaa9a07..e467c9c3e31 100644 --- a/src/CoreBundle/DataTransformer/SkillTreeNodeTransformer.php +++ b/src/CoreBundle/DataTransformer/SkillTreeNodeTransformer.php @@ -6,21 +6,18 @@ namespace Chamilo\CoreBundle\DataTransformer; -use ApiPlatform\Core\DataTransformer\DataTransformerInterface; use Chamilo\CoreBundle\ApiResource\SkillTreeNode; use Chamilo\CoreBundle\Entity\Skill; use Chamilo\CoreBundle\Settings\SettingsManager; -readonly class SkillTreeNodeTransformer implements DataTransformerInterface +readonly class SkillTreeNodeTransformer { public function __construct( private SettingsManager $settingsManager, ) {} - public function transform($object, string $to, array $context = []) + public function transform(Skill $object, string $to, array $context = []): SkillTreeNode { - \assert($object instanceof Skill); - $skillNode = new SkillTreeNode(); $skillNode->id = $object->getId(); $skillNode->title = $object->getTitle(); @@ -41,9 +38,4 @@ public function transform($object, string $to, array $context = []) return $skillNode; } - - public function supportsTransformation($data, string $to, array $context = []): bool - { - return $data instanceof Skill && SkillTreeNode::class === $to; - } } diff --git a/src/CoreBundle/Entity/Language.php b/src/CoreBundle/Entity/Language.php index 024d3dccc29..ce36a7c909f 100644 --- a/src/CoreBundle/Entity/Language.php +++ b/src/CoreBundle/Entity/Language.php @@ -6,8 +6,8 @@ namespace Chamilo\CoreBundle\Entity; -use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter; use ApiPlatform\Doctrine\Orm\Filter\BooleanFilter; +use ApiPlatform\Doctrine\Orm\Filter\OrderFilter; use ApiPlatform\Metadata\ApiFilter; use ApiPlatform\Metadata\ApiResource; use Chamilo\CoreBundle\Entity\Listener\LanguageListener; diff --git a/src/CoreBundle/Entity/Legal.php b/src/CoreBundle/Entity/Legal.php index bec77960638..f93cdca047d 100644 --- a/src/CoreBundle/Entity/Legal.php +++ b/src/CoreBundle/Entity/Legal.php @@ -6,7 +6,7 @@ namespace Chamilo\CoreBundle\Entity; -use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter; +use ApiPlatform\Doctrine\Orm\Filter\OrderFilter; use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; use ApiPlatform\Metadata\ApiFilter; use ApiPlatform\Metadata\ApiResource; diff --git a/src/CoreBundle/Entity/Session.php b/src/CoreBundle/Entity/Session.php index 031044eaac5..70702e7b699 100644 --- a/src/CoreBundle/Entity/Session.php +++ b/src/CoreBundle/Entity/Session.php @@ -6,7 +6,6 @@ namespace Chamilo\CoreBundle\Entity; -use ApiPlatform\Core\Serializer\Filter\GroupFilter; use ApiPlatform\Doctrine\Orm\Filter\OrderFilter; use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; use ApiPlatform\Metadata\ApiFilter; @@ -17,6 +16,7 @@ use ApiPlatform\Metadata\Link; use ApiPlatform\Metadata\Post; use ApiPlatform\Metadata\Put; +use ApiPlatform\Serializer\Filter\GroupFilter; use ApiPlatform\Serializer\Filter\PropertyFilter; use Chamilo\CoreBundle\Controller\Api\CreateSessionWithUsersAndCoursesAction; use Chamilo\CoreBundle\Dto\CreateSessionWithUsersAndCoursesInput; diff --git a/src/CoreBundle/State/AccessUrlRelColorThemeStateProcessor.php b/src/CoreBundle/State/AccessUrlRelColorThemeStateProcessor.php index 204ca15a394..04e8291f2d0 100644 --- a/src/CoreBundle/State/AccessUrlRelColorThemeStateProcessor.php +++ b/src/CoreBundle/State/AccessUrlRelColorThemeStateProcessor.php @@ -12,6 +12,9 @@ use Chamilo\CoreBundle\ServiceHelper\AccessUrlHelper; use Doctrine\ORM\EntityManagerInterface; +/** + * @implements ProcessorInterface + */ final class AccessUrlRelColorThemeStateProcessor implements ProcessorInterface { public function __construct( diff --git a/src/CoreBundle/State/AccessUrlRelColorThemeStateProvider.php b/src/CoreBundle/State/AccessUrlRelColorThemeStateProvider.php index a0b1a57a1b9..b85f0f469b0 100644 --- a/src/CoreBundle/State/AccessUrlRelColorThemeStateProvider.php +++ b/src/CoreBundle/State/AccessUrlRelColorThemeStateProvider.php @@ -8,17 +8,18 @@ use ApiPlatform\State\ProviderInterface; use Chamilo\CoreBundle\Entity\AccessUrlRelColorTheme; use Chamilo\CoreBundle\ServiceHelper\AccessUrlHelper; +use Doctrine\Common\Collections\Collection; /** * @template-implements ProviderInterface */ -class AccessUrlRelColorThemeStateProvider implements ProviderInterface +readonly class AccessUrlRelColorThemeStateProvider implements ProviderInterface { public function __construct( - private readonly AccessUrlHelper $accessUrlHelper, + private AccessUrlHelper $accessUrlHelper, ) {} - public function provide(Operation $operation, array $uriVariables = [], array $context = []) + public function provide(Operation $operation, array $uriVariables = [], array $context = []): Collection { $colorThemes = $this->accessUrlHelper->getCurrent()->getColorThemes(); diff --git a/src/CoreBundle/State/CAttendanceStateProcessor.php b/src/CoreBundle/State/CAttendanceStateProcessor.php index 3fc7d2a651d..b454b1a5f4b 100644 --- a/src/CoreBundle/State/CAttendanceStateProcessor.php +++ b/src/CoreBundle/State/CAttendanceStateProcessor.php @@ -18,6 +18,9 @@ use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; +/** + * @implements ProcessorInterface + */ final class CAttendanceStateProcessor implements ProcessorInterface { public function __construct( diff --git a/src/CoreBundle/State/CCalendarEventStateProcessor.php b/src/CoreBundle/State/CCalendarEventStateProcessor.php index b02a62800c9..4d8d240dac0 100644 --- a/src/CoreBundle/State/CCalendarEventStateProcessor.php +++ b/src/CoreBundle/State/CCalendarEventStateProcessor.php @@ -10,17 +10,18 @@ use ApiPlatform\State\ProcessorInterface; use Chamilo\CoreBundle\Entity\AgendaReminder; use Chamilo\CoreBundle\Entity\User; -use Chamilo\CoreBundle\Settings\SettingsManager; use Chamilo\CourseBundle\Entity\CCalendarEvent; use Exception; use Symfony\Bundle\SecurityBundle\Security; +/** + * @implements ProcessorInterface + */ final class CCalendarEventStateProcessor implements ProcessorInterface { public function __construct( private readonly ProcessorInterface $persistProcessor, private readonly Security $security, - private readonly SettingsManager $settingsManager, ) {} /** diff --git a/src/CoreBundle/State/CStudentPublicationPostStateProcessor.php b/src/CoreBundle/State/CStudentPublicationPostStateProcessor.php index 47ae06cb946..dc6ac415a79 100644 --- a/src/CoreBundle/State/CStudentPublicationPostStateProcessor.php +++ b/src/CoreBundle/State/CStudentPublicationPostStateProcessor.php @@ -23,6 +23,9 @@ use Symfony\Component\Routing\RouterInterface; use Symfony\Contracts\Translation\TranslatorInterface; +/** + * @implements ProcessorInterface + */ final class CStudentPublicationPostStateProcessor implements ProcessorInterface { public function __construct( @@ -34,8 +37,12 @@ public function __construct( private readonly SettingsManager $settingsManager, ) {} - public function process($data, Operation $operation, array $uriVariables = [], array $context = []) - { + public function process( + $data, + Operation $operation, + array $uriVariables = [], + array $context = [] + ): CStudentPublication { $result = $this->persistProcessor->process($data, $operation, $uriVariables, $context); /** @var CStudentPublication $publication */ diff --git a/src/CoreBundle/State/CToolStateProvider.php b/src/CoreBundle/State/CToolStateProvider.php index 69fe1a198aa..4d88df269e0 100644 --- a/src/CoreBundle/State/CToolStateProvider.php +++ b/src/CoreBundle/State/CToolStateProvider.php @@ -10,9 +10,13 @@ use ApiPlatform\Metadata\Operation; use ApiPlatform\State\Pagination\PartialPaginatorInterface; use ApiPlatform\State\ProviderInterface; +use Chamilo\CoreBundle\ApiResource\CourseTool; +use Chamilo\CoreBundle\DataTransformer\CourseToolDataTranformer; +use Chamilo\CoreBundle\Entity\Course; use Chamilo\CoreBundle\Entity\ResourceLink; use Chamilo\CoreBundle\Entity\User; use Chamilo\CoreBundle\Settings\SettingsManager; +use Chamilo\CoreBundle\Tool\AbstractTool; use Chamilo\CoreBundle\Tool\ToolChain; use Chamilo\CoreBundle\Traits\CourseFromRequestTrait; use Chamilo\CourseBundle\Entity\CTool; @@ -27,6 +31,8 @@ final class CToolStateProvider implements ProviderInterface { use CourseFromRequestTrait; + private CourseToolDataTranformer $transformer; + public function __construct( private readonly CollectionProvider $provider, protected EntityManagerInterface $entityManager, @@ -34,7 +40,13 @@ public function __construct( private readonly Security $security, private readonly ToolChain $toolChain, protected RequestStack $requestStack, - ) {} + ) { + $this->transformer = new CourseToolDataTranformer( + $this->requestStack, + $this->entityManager, + $this->toolChain + ); + } public function provide(Operation $operation, array $uriVariables = [], array $context = []): array { @@ -93,7 +105,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c } } - $results[] = $cTool; + $results[] = $this->transformer->transform($cTool); } return $results; diff --git a/src/CoreBundle/State/CalendarEventStateProvider.php b/src/CoreBundle/State/CalendarEventStateProvider.php index a1fda226942..365b806231c 100644 --- a/src/CoreBundle/State/CalendarEventStateProvider.php +++ b/src/CoreBundle/State/CalendarEventStateProvider.php @@ -7,21 +7,30 @@ use ApiPlatform\Doctrine\Orm\State\CollectionProvider; use ApiPlatform\Metadata\Operation; use ApiPlatform\State\ProviderInterface; +use Chamilo\CoreBundle\ApiResource\CalendarEvent; +use Chamilo\CoreBundle\DataTransformer\CalendarEventTransformer; use Chamilo\CoreBundle\Entity\AccessUrl; +use Chamilo\CoreBundle\Entity\AgendaReminder; use Chamilo\CoreBundle\Entity\Session; +use Chamilo\CoreBundle\Entity\SessionRelCourse; use Chamilo\CoreBundle\Entity\User; +use Chamilo\CoreBundle\Repository\Node\UsergroupRepository; use Chamilo\CoreBundle\Repository\SessionRepository; use Chamilo\CoreBundle\ServiceHelper\AccessUrlHelper; use Chamilo\CoreBundle\Settings\SettingsManager; use Chamilo\CourseBundle\Entity\CCalendarEvent; use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; +use Symfony\Component\Routing\RouterInterface; /** * @template-implements ProviderInterface */ final class CalendarEventStateProvider implements ProviderInterface { + private CalendarEventTransformer $transformer; + public function __construct( private readonly CollectionProvider $collectionProvider, private readonly Security $security, @@ -29,7 +38,15 @@ public function __construct( private readonly SessionRepository $sessionRepository, private readonly RequestStack $requestStack, private readonly SettingsManager $settingsManager, - ) {} + private readonly RouterInterface $router, + private readonly UsergroupRepository $usergroupRepository, + ) { + $this->transformer = new CalendarEventTransformer( + $this->router, + $this->usergroupRepository, + $this->settingsManager + ); + } public function provide(Operation $operation, array $uriVariables = [], array $context = []): array { @@ -58,7 +75,10 @@ public function provide(Operation $operation, array $uriVariables = [], array $c $userSessions = $this->getSessionList($user, $accessUrl, $context); } - return array_merge($cCalendarEvents, $userSessions); + return array_map( + fn($object) => $this->transformer->transform($object), + array_merge($cCalendarEvents, $userSessions), + ); } /** diff --git a/src/CoreBundle/State/ColorThemeStateProcessor.php b/src/CoreBundle/State/ColorThemeStateProcessor.php index b0572cf8872..52a0c549aa9 100644 --- a/src/CoreBundle/State/ColorThemeStateProcessor.php +++ b/src/CoreBundle/State/ColorThemeStateProcessor.php @@ -19,6 +19,9 @@ use const DIRECTORY_SEPARATOR; use const PHP_EOL; +/** + * @implements ProcessorInterface + */ final class ColorThemeStateProcessor implements ProcessorInterface { public function __construct( @@ -29,12 +32,7 @@ public function __construct( private readonly FilesystemOperator $filesystem, ) {} - /** - * @param mixed $data - * - * @throws FilesystemException - */ - public function process($data, Operation $operation, array $uriVariables = [], array $context = []) + public function process($data, Operation $operation, array $uriVariables = [], array $context = []): ?ColorTheme { \assert($data instanceof ColorTheme); diff --git a/src/CoreBundle/State/MessageProcessor.php b/src/CoreBundle/State/MessageProcessor.php index e3784dc0449..b3a6c1fbdc5 100644 --- a/src/CoreBundle/State/MessageProcessor.php +++ b/src/CoreBundle/State/MessageProcessor.php @@ -12,27 +12,27 @@ use Chamilo\CoreBundle\Entity\Message; use Chamilo\CoreBundle\Entity\MessageAttachment; use Chamilo\CoreBundle\Entity\MessageRelUser; +use Chamilo\CoreBundle\Entity\User; use Chamilo\CoreBundle\Repository\ResourceNodeRepository; use Doctrine\ORM\EntityManagerInterface; use LogicException; use Notification; use Symfony\Bundle\SecurityBundle\Security; -use Symfony\Component\HttpFoundation\RequestStack; -use Vich\UploaderBundle\Storage\FlysystemStorage; -final class MessageProcessor implements ProcessorInterface +/** + * @implements ProcessorInterface + */ +final readonly class MessageProcessor implements ProcessorInterface { public function __construct( - private readonly ProcessorInterface $persistProcessor, - private readonly ProcessorInterface $removeProcessor, - private readonly FlysystemStorage $storage, - private readonly EntityManagerInterface $entityManager, - private readonly ResourceNodeRepository $resourceNodeRepository, - private readonly Security $security, - private readonly RequestStack $requestStack + private ProcessorInterface $persistProcessor, + private ProcessorInterface $removeProcessor, + private EntityManagerInterface $entityManager, + private ResourceNodeRepository $resourceNodeRepository, + private Security $security, ) {} - public function process($data, Operation $operation, array $uriVariables = [], array $context = []) + public function process($data, Operation $operation, array $uriVariables = [], array $context = []): ?Message { if ($operation instanceof DeleteOperationInterface) { return $this->removeProcessor->process($data, $operation, $uriVariables, $context); @@ -51,6 +51,7 @@ public function process($data, Operation $operation, array $uriVariables = [], a } } + /** @var User $user */ $user = $this->security->getUser(); if (!$user) { throw new LogicException('User not found.'); diff --git a/src/CoreBundle/State/MessageStateProvider.php b/src/CoreBundle/State/MessageStateProvider.php index 562af6b9695..e5d45211886 100644 --- a/src/CoreBundle/State/MessageStateProvider.php +++ b/src/CoreBundle/State/MessageStateProvider.php @@ -9,9 +9,11 @@ use ApiPlatform\Doctrine\Orm\Paginator; use ApiPlatform\Doctrine\Orm\State\CollectionProvider; use ApiPlatform\Doctrine\Orm\State\ItemProvider; +use ApiPlatform\Metadata\CollectionOperationInterface; use ApiPlatform\Metadata\Operation; use ApiPlatform\State\ProviderInterface; use Chamilo\CoreBundle\Entity\Message; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\QueryBuilder; use LogicException; @@ -36,11 +38,9 @@ public function __construct( * * @return Paginator|Message|null */ - public function provide(Operation $operation, array $uriVariables = [], array $context = []) + public function provide(Operation $operation, array $uriVariables = [], array $context = []): Paginator|Message|null { - $isCollection = 'collection' === $context['operation_type']; - - if ($isCollection) { + if ($operation instanceof CollectionOperationInterface) { return $this->handleCollection($operation, $context); } diff --git a/src/CoreBundle/State/SkillTreeStateProvider.php b/src/CoreBundle/State/SkillTreeStateProvider.php index 055486f1a47..5629906a0e3 100644 --- a/src/CoreBundle/State/SkillTreeStateProvider.php +++ b/src/CoreBundle/State/SkillTreeStateProvider.php @@ -8,8 +8,11 @@ use ApiPlatform\Metadata\Operation; use ApiPlatform\State\ProviderInterface; +use Chamilo\CoreBundle\ApiResource\SkillTreeNode; +use Chamilo\CoreBundle\DataTransformer\SkillTreeNodeTransformer; use Chamilo\CoreBundle\Entity\Skill; use Chamilo\CoreBundle\Repository\SkillRepository; +use Chamilo\CoreBundle\Settings\SettingsManager; use Doctrine\Common\Collections\Collection; /** @@ -17,9 +20,16 @@ */ readonly class SkillTreeStateProvider implements ProviderInterface { + private SkillTreeNodeTransformer $transformer; + public function __construct( private SkillRepository $skillRepo, - ) {} + private SettingsManager $settingsManager, + ) { + $this->transformer = new SkillTreeNodeTransformer( + $this->settingsManager + ); + } public function provide(Operation $operation, array $uriVariables = [], array $context = []): array|Collection { @@ -30,6 +40,8 @@ public function provide(Operation $operation, array $uriVariables = [], array $c return []; } - return $root->getChildSkills(); + return $root->getChildSkills() + ->map(fn (Skill $childSkill) => $this->transformer->transform($childSkill)) + ; } } diff --git a/src/CoreBundle/State/UserRelUserStateProcessor.php b/src/CoreBundle/State/UserRelUserStateProcessor.php index 0c5bd6c65ff..0e5168d92b3 100644 --- a/src/CoreBundle/State/UserRelUserStateProcessor.php +++ b/src/CoreBundle/State/UserRelUserStateProcessor.php @@ -13,6 +13,9 @@ use Chamilo\CoreBundle\Entity\UserRelUser; use Doctrine\ORM\EntityManagerInterface; +/** + * @implements ProcessorInterface + */ final class UserRelUserStateProcessor implements ProcessorInterface { public function __construct( diff --git a/src/CoreBundle/State/UsergroupPostStateProcessor.php b/src/CoreBundle/State/UsergroupPostStateProcessor.php index 20ace5e5fb4..a0826b4e6fe 100644 --- a/src/CoreBundle/State/UsergroupPostStateProcessor.php +++ b/src/CoreBundle/State/UsergroupPostStateProcessor.php @@ -12,6 +12,9 @@ use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\HttpFoundation\RequestStack; +/** + * @implements ProcessorInterface + */ final class UsergroupPostStateProcessor implements ProcessorInterface { private ProcessorInterface $processor; @@ -31,7 +34,7 @@ public function __construct( $this->requestStack = $requestStack; } - public function process($data, Operation $operation, array $uriVariables = [], array $context = []) + public function process($data, Operation $operation, array $uriVariables = [], array $context = []): Usergroup { /** @var Usergroup $usergroup */ $usergroup = $this->processor->process($data, $operation, $uriVariables, $context); diff --git a/src/CourseBundle/Entity/CForumCategory.php b/src/CourseBundle/Entity/CForumCategory.php index 51ff4163a62..4f2f0efad85 100644 --- a/src/CourseBundle/Entity/CForumCategory.php +++ b/src/CourseBundle/Entity/CForumCategory.php @@ -46,7 +46,6 @@ public function __construct() { $this->catComment = ''; $this->locked = 0; - $this->catOrder = 0; $this->forums = new ArrayCollection(); } diff --git a/src/CourseBundle/Entity/CQuizAnswer.php b/src/CourseBundle/Entity/CQuizAnswer.php index 9e7deac0b7a..2855a576252 100644 --- a/src/CourseBundle/Entity/CQuizAnswer.php +++ b/src/CourseBundle/Entity/CQuizAnswer.php @@ -60,7 +60,6 @@ public function __construct() $this->ponderation = 0.0; $this->hotspotCoordinates = null; $this->hotspotType = null; - $this->destination = null; $this->answerCode = null; } diff --git a/src/CourseBundle/Entity/CTool.php b/src/CourseBundle/Entity/CTool.php index 537b1cee876..e3d95369b31 100644 --- a/src/CourseBundle/Entity/CTool.php +++ b/src/CourseBundle/Entity/CTool.php @@ -28,11 +28,12 @@ #[ApiResource( operations: [ - new GetCollection(), + new GetCollection( + output: CourseTool::class, + provider: CToolStateProvider::class, + ), ], normalizationContext: ['groups' => ['ctool:read']], - output: CourseTool::class, - provider: CToolStateProvider::class, )] #[ORM\Table(name: 'c_tool')] #[ORM\Index(columns: ['c_id'], name: 'course')] diff --git a/src/CourseBundle/Entity/CToolIntro.php b/src/CourseBundle/Entity/CToolIntro.php index 29926b9af7c..d24c814c974 100644 --- a/src/CourseBundle/Entity/CToolIntro.php +++ b/src/CourseBundle/Entity/CToolIntro.php @@ -26,7 +26,22 @@ use Symfony\Component\Uid\Uuid; use Symfony\Component\Validator\Constraints as Assert; -#[ApiResource(operations: [new Get(security: 'is_granted(\'VIEW\', object)'), new Put(security: 'is_granted(\'EDIT\', object)'), new Delete(security: 'is_granted(\'DELETE\', object)'), new GetCollection(security: 'is_granted(\'ROLE_USER\')'), new Post(securityPostDenormalize: 'is_granted(\'CREATE\', object)')], security: 'is_granted(\'ROLE_ADMIN\') or is_granted(\'ROLE_CURRENT_COURSE_TEACHER\')', denormalizationContext: ['groups' => ['c_tool_intro:write']], normalizationContext: ['groups' => ['c_tool_intro:read']])] +#[ApiResource( + operations: [ + new Get(security: "is_granted('VIEW', object)"), + new Put(security: "is_granted('EDIT', object)"), + new Delete(security: "is_granted('DELETE', object)"), + new GetCollection(security: "is_granted('ROLE_USER')"), + new Post(securityPostDenormalize: "is_granted('CREATE', object)"), + ], + normalizationContext: [ + 'groups' => ['c_tool_intro:read'], + ], + denormalizationContext: [ + 'groups' => ['c_tool_intro:write'], + ], + security: "is_granted('ROLE_ADMIN') or is_granted('ROLE_CURRENT_COURSE_TEACHER')", +)] #[ORM\Table(name: 'c_tool_intro')] #[ORM\Entity(repositoryClass: CToolIntroRepository::class)] #[ApiFilter(filterClass: SearchFilter::class, properties: ['courseTool' => 'exact'])] @@ -39,51 +54,62 @@ class CToolIntro extends AbstractResource implements ResourceInterface, Resource #[ORM\Id] #[ORM\GeneratedValue] protected ?int $iid = null; + #[Assert\NotNull] #[Groups(['c_tool_intro:read', 'c_tool_intro:write'])] #[ORM\Column(name: 'intro_text', type: 'text', nullable: false)] protected string $introText; + #[Assert\NotNull] #[Groups(['c_tool_intro:read', 'c_tool_intro:write'])] #[ORM\ManyToOne(targetEntity: CTool::class)] #[ORM\JoinColumn(name: 'c_tool_id', referencedColumnName: 'iid', nullable: false, onDelete: 'CASCADE')] protected CTool $courseTool; + public function __toString(): string { return $this->getIntroText(); } + public function getIid(): ?int { return $this->iid; } + public function getCourseTool(): CTool { return $this->courseTool; } + public function setCourseTool(CTool $courseTool): self { $this->courseTool = $courseTool; return $this; } + public function setIntroText(string $introText): self { $this->introText = $introText; return $this; } + public function getIntroText(): string { return $this->introText; } + public function getResourceIdentifier(): int|Uuid { return $this->getIid(); } + public function getResourceName(): string { return $this->getCourseTool()->getTitle(); } + public function setResourceName(string $name): self { return $this; diff --git a/tests/AbstractApiTest.php b/tests/AbstractApiTest.php index f834f7d4b10..f169c02a160 100644 --- a/tests/AbstractApiTest.php +++ b/tests/AbstractApiTest.php @@ -1,7 +1,7 @@ assertResponseIsSuccessful(); } - public function urlProvider() + public function urlProvider(): \Generator { yield ['/']; yield ['/login']; diff --git a/tests/CoreBundle/Repository/SocialPostRepositoryTest.php b/tests/CoreBundle/Repository/SocialPostRepositoryTest.php index 07ff4a12ebb..7d5d8fe9423 100644 --- a/tests/CoreBundle/Repository/SocialPostRepositoryTest.php +++ b/tests/CoreBundle/Repository/SocialPostRepositoryTest.php @@ -112,8 +112,6 @@ public function testPostToOwnWall(): void '@id' => $studentIri, 'username' => $student->getUsername(), ], - 'userReceiver' => null, - 'groupReceiver' => null, ]); $response = $client->request( @@ -177,10 +175,8 @@ public function testPostToFriendsWall(): void '@id' => $student1Iri, 'username' => $student1->getUsername(), ], - 'userReceiver' => null, 'content' => 'Hello world', 'type' => SocialPost::TYPE_WALL_POST, - 'groupReceiver' => null, ]); // student1 posts in student2's wall @@ -210,7 +206,6 @@ public function testPostToFriendsWall(): void '@id' => $student2Iri, 'username' => $student2->getUsername(), ], - 'groupReceiver' => null, ]); // student1 views student2's wall diff --git a/tests/scripts/synchronize_user_base_from_ldap.php b/tests/scripts/synchronize_user_base_from_ldap.php index 07eb0a35148..ea96acbac43 100644 --- a/tests/scripts/synchronize_user_base_from_ldap.php +++ b/tests/scripts/synchronize_user_base_from_ldap.php @@ -57,8 +57,7 @@ use Chamilo\CoreBundle\Entity\ExtraFieldValues; use Chamilo\CoreBundle\Entity\ExtraField; use Chamilo\CoreBundle\Entity\TrackEDefault; -use Chamilo\UserBundle\Entity\User; -use Doctrine\DBAL\FetchMode; +use Chamilo\CoreBundle\Entity\User; use Doctrine\ORM\OptimisticLockException; if (php_sapi_name() !== 'cli') { @@ -127,8 +126,8 @@ $extraFieldMap = $tableFieldMap[EXTRA_ARRAY_KEY]; unset($tableFieldMap[EXTRA_ARRAY_KEY]); } - $extraFieldRepository = Database::getManager()->getRepository('ChamiloCoreBundle:ExtraField'); - $extraFieldValueRepository = Database::getManager()->getRepository('ChamiloCoreBundle:ExtraFieldValues'); + $extraFieldRepository = Database::getManager()->getRepository(ExtraField::class); + $extraFieldValueRepository = Database::getManager()->getRepository(ExtraFieldValues::class); foreach ([false => $tableFieldMap, true => $extraFieldMap] as $areExtra => $fields) { foreach ($fields as $name => $value) { $userField = (object)[ @@ -457,7 +456,7 @@ where default_event_type=\'user_disable\' and default_value_type=\'user_id\' group by default_value having max(default_date) < date_sub(now(), interval 3 year)' - )->fetchAll(FetchMode::COLUMN) as $userId) { + )->fetchFirstColumn() as $userId) { $longDisabledUserIds[] = $userId; } $anonymizedUserIds = []; @@ -465,7 +464,7 @@ 'select distinct default_value from track_e_default where default_event_type=\'user_anonymized\' and default_value_type=\'user_id\'' - )->fetchAll(FetchMode::COLUMN) as $userId) { + )->fetchFirstColumn() as $userId) { $anonymizedUserIds[] = $userId; } foreach (array_diff($longDisabledUserIds, $anonymizedUserIds) as $userId) {