Compare commits
No commits in common. "9747eefe470e054ca88401e2ebc8dae31d5f817c" and "bae8ee9a24b5a1e8eca9a34113b8d9b09694848a" have entirely different histories.
9747eefe47
...
bae8ee9a24
|
@ -14,6 +14,7 @@
|
||||||
"doctrine/doctrine-migrations-bundle": "^3.2",
|
"doctrine/doctrine-migrations-bundle": "^3.2",
|
||||||
"doctrine/orm": "^2.14",
|
"doctrine/orm": "^2.14",
|
||||||
"ghunti/highcharts-php": "^5.0",
|
"ghunti/highcharts-php": "^5.0",
|
||||||
|
"jms/serializer-bundle": "^5.2",
|
||||||
"knplabs/knp-paginator-bundle": "^6.2",
|
"knplabs/knp-paginator-bundle": "^6.2",
|
||||||
"league/commonmark": "^2.4",
|
"league/commonmark": "^2.4",
|
||||||
"phpdocumentor/reflection-docblock": "^5.3",
|
"phpdocumentor/reflection-docblock": "^5.3",
|
||||||
|
@ -33,7 +34,6 @@
|
||||||
"symfony/property-info": "6.3.*",
|
"symfony/property-info": "6.3.*",
|
||||||
"symfony/runtime": "6.3.*",
|
"symfony/runtime": "6.3.*",
|
||||||
"symfony/security-bundle": "6.3.*",
|
"symfony/security-bundle": "6.3.*",
|
||||||
"symfony/serializer": "6.3.*",
|
|
||||||
"symfony/string": "6.3.*",
|
"symfony/string": "6.3.*",
|
||||||
"symfony/translation": "6.3.*",
|
"symfony/translation": "6.3.*",
|
||||||
"symfony/twig-bundle": "6.3.*",
|
"symfony/twig-bundle": "6.3.*",
|
||||||
|
|
343
composer.lock
generated
343
composer.lock
generated
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "0cb307d1ad554ab97a56f5805e8c6adb",
|
"content-hash": "274812d219a3d19c925c0e67b5f86926",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "dflydev/dot-access-data",
|
"name": "dflydev/dot-access-data",
|
||||||
|
@ -1689,6 +1689,253 @@
|
||||||
},
|
},
|
||||||
"time": "2023-04-26T21:37:31+00:00"
|
"time": "2023-04-26T21:37:31+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "jms/metadata",
|
||||||
|
"version": "2.8.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/schmittjoh/metadata.git",
|
||||||
|
"reference": "7ca240dcac0c655eb15933ee55736ccd2ea0d7a6"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/schmittjoh/metadata/zipball/7ca240dcac0c655eb15933ee55736ccd2ea0d7a6",
|
||||||
|
"reference": "7ca240dcac0c655eb15933ee55736ccd2ea0d7a6",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^7.2|^8.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"doctrine/cache": "^1.0",
|
||||||
|
"doctrine/coding-standard": "^8.0",
|
||||||
|
"mikey179/vfsstream": "^1.6.7",
|
||||||
|
"phpunit/phpunit": "^8.5|^9.0",
|
||||||
|
"psr/container": "^1.0|^2.0",
|
||||||
|
"symfony/cache": "^3.1|^4.0|^5.0",
|
||||||
|
"symfony/dependency-injection": "^3.1|^4.0|^5.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "2.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Metadata\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Johannes M. Schmitt",
|
||||||
|
"email": "schmittjoh@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Asmir Mustafic",
|
||||||
|
"email": "goetas@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Class/method/property metadata management in PHP",
|
||||||
|
"keywords": [
|
||||||
|
"annotations",
|
||||||
|
"metadata",
|
||||||
|
"xml",
|
||||||
|
"yaml"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/schmittjoh/metadata/issues",
|
||||||
|
"source": "https://github.com/schmittjoh/metadata/tree/2.8.0"
|
||||||
|
},
|
||||||
|
"time": "2023-02-15T13:44:18+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "jms/serializer",
|
||||||
|
"version": "3.27.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/schmittjoh/serializer.git",
|
||||||
|
"reference": "e8c812460d7b47b15bc0ccd78901276bd44ad452"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/schmittjoh/serializer/zipball/e8c812460d7b47b15bc0ccd78901276bd44ad452",
|
||||||
|
"reference": "e8c812460d7b47b15bc0ccd78901276bd44ad452",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"doctrine/annotations": "^1.13 || ^2.0",
|
||||||
|
"doctrine/instantiator": "^1.0.3 || ^2.0",
|
||||||
|
"doctrine/lexer": "^2.0 || ^3.0",
|
||||||
|
"jms/metadata": "^2.6",
|
||||||
|
"php": "^7.2||^8.0",
|
||||||
|
"phpstan/phpdoc-parser": "^0.4 || ^0.5 || ^1.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"doctrine/coding-standard": "^8.1",
|
||||||
|
"doctrine/orm": "~2.1",
|
||||||
|
"doctrine/persistence": "^1.3.3|^2.0|^3.0",
|
||||||
|
"doctrine/phpcr-odm": "^1.3|^2.0",
|
||||||
|
"ext-pdo_sqlite": "*",
|
||||||
|
"jackalope/jackalope-doctrine-dbal": "^1.1.5",
|
||||||
|
"ocramius/proxy-manager": "^1.0|^2.0",
|
||||||
|
"phpbench/phpbench": "^1.0",
|
||||||
|
"phpstan/phpstan": "^1.0.2",
|
||||||
|
"phpunit/phpunit": "^8.5.21||^9.0||^10.0",
|
||||||
|
"psr/container": "^1.0|^2.0",
|
||||||
|
"symfony/dependency-injection": "^3.0|^4.0|^5.0|^6.0",
|
||||||
|
"symfony/expression-language": "^3.2|^4.0|^5.0|^6.0",
|
||||||
|
"symfony/filesystem": "^3.0|^4.0|^5.0|^6.0",
|
||||||
|
"symfony/form": "^3.0|^4.0|^5.0|^6.0",
|
||||||
|
"symfony/translation": "^3.0|^4.0|^5.0|^6.0",
|
||||||
|
"symfony/uid": "^5.1|^6.0",
|
||||||
|
"symfony/validator": "^3.1.9|^4.0|^5.0|^6.0",
|
||||||
|
"symfony/yaml": "^3.3|^4.0|^5.0|^6.0",
|
||||||
|
"twig/twig": "~1.34|~2.4|^3.0"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"doctrine/collections": "Required if you like to use doctrine collection types as ArrayCollection.",
|
||||||
|
"symfony/cache": "Required if you like to use cache functionality.",
|
||||||
|
"symfony/uid": "Required if you'd like to serialize UID objects.",
|
||||||
|
"symfony/yaml": "Required if you'd like to use the YAML metadata format."
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "3.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"JMS\\Serializer\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Johannes M. Schmitt",
|
||||||
|
"email": "schmittjoh@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Asmir Mustafic",
|
||||||
|
"email": "goetas@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Library for (de-)serializing data of any complexity; supports XML, and JSON.",
|
||||||
|
"homepage": "http://jmsyst.com/libs/serializer",
|
||||||
|
"keywords": [
|
||||||
|
"deserialization",
|
||||||
|
"jaxb",
|
||||||
|
"json",
|
||||||
|
"serialization",
|
||||||
|
"xml"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/schmittjoh/serializer/issues",
|
||||||
|
"source": "https://github.com/schmittjoh/serializer/tree/3.27.0"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/goetas",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2023-07-29T22:33:44+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "jms/serializer-bundle",
|
||||||
|
"version": "5.3.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/schmittjoh/JMSSerializerBundle.git",
|
||||||
|
"reference": "3279738a958454793ca1e318a7dab6cfcff60124"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/schmittjoh/JMSSerializerBundle/zipball/3279738a958454793ca1e318a7dab6cfcff60124",
|
||||||
|
"reference": "3279738a958454793ca1e318a7dab6cfcff60124",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"jms/metadata": "^2.5",
|
||||||
|
"jms/serializer": "^3.20",
|
||||||
|
"php": "^7.2 || ^8.0",
|
||||||
|
"symfony/dependency-injection": "^3.4 || ^4.0 || ^5.0 || ^6.0",
|
||||||
|
"symfony/framework-bundle": "^3.4 || ^4.0 || ^5.0 || ^6.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"doctrine/coding-standard": "^8.1",
|
||||||
|
"doctrine/orm": "^2.4",
|
||||||
|
"phpunit/phpunit": "^8.0 || ^9.0",
|
||||||
|
"symfony/expression-language": "^3.4 || ^4.0 || ^5.0 || ^6.0",
|
||||||
|
"symfony/finder": "^3.4 || ^4.0 || ^5.0 || ^6.0",
|
||||||
|
"symfony/form": "^3.4 || ^4.0 || ^5.0 || ^6.0",
|
||||||
|
"symfony/stopwatch": "^3.4 || ^4.0 || ^5.0 || ^6.0",
|
||||||
|
"symfony/templating": "^3.4 || ^4.0 || ^5.0 || ^6.0",
|
||||||
|
"symfony/twig-bundle": "^3.4 || ^4.0 || ^5.0 || ^6.0",
|
||||||
|
"symfony/uid": "^5.1 || ^6.0",
|
||||||
|
"symfony/validator": "^3.4 || ^4.0 || ^5.0 || ^6.0",
|
||||||
|
"symfony/yaml": "^3.4 || ^4.0 || ^5.0 || ^6.0"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"symfony/expression-language": "Required for opcache preloading ^3.4 || ^4.0 || ^5.0 || ^6.0",
|
||||||
|
"symfony/finder": "Required for cache warmup, supported versions ^3.4 || ^4.0 || ^5.0 || ^6.0"
|
||||||
|
},
|
||||||
|
"type": "symfony-bundle",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "5.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"JMS\\SerializerBundle\\": ""
|
||||||
|
},
|
||||||
|
"exclude-from-classmap": [
|
||||||
|
"/Tests/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Johannes M. Schmitt",
|
||||||
|
"email": "schmittjoh@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Asmir Mustafic",
|
||||||
|
"email": "goetas@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Allows you to easily serialize, and deserialize data of any complexity",
|
||||||
|
"homepage": "http://jmsyst.com/bundles/JMSSerializerBundle",
|
||||||
|
"keywords": [
|
||||||
|
"deserialization",
|
||||||
|
"json",
|
||||||
|
"serialization",
|
||||||
|
"xml"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/schmittjoh/JMSSerializerBundle/issues",
|
||||||
|
"source": "https://github.com/schmittjoh/JMSSerializerBundle/tree/5.3.1"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/goetas",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2023-06-13T14:47:57+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "knplabs/knp-components",
|
"name": "knplabs/knp-components",
|
||||||
"version": "v4.2.0",
|
"version": "v4.2.0",
|
||||||
|
@ -6192,100 +6439,6 @@
|
||||||
],
|
],
|
||||||
"time": "2023-07-13T14:29:38+00:00"
|
"time": "2023-07-13T14:29:38+00:00"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "symfony/serializer",
|
|
||||||
"version": "v6.3.3",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/symfony/serializer.git",
|
|
||||||
"reference": "33deb86d212893042d7758d452aa39d19ca0efe3"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/symfony/serializer/zipball/33deb86d212893042d7758d452aa39d19ca0efe3",
|
|
||||||
"reference": "33deb86d212893042d7758d452aa39d19ca0efe3",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=8.1",
|
|
||||||
"symfony/deprecation-contracts": "^2.5|^3",
|
|
||||||
"symfony/polyfill-ctype": "~1.8"
|
|
||||||
},
|
|
||||||
"conflict": {
|
|
||||||
"doctrine/annotations": "<1.12",
|
|
||||||
"phpdocumentor/reflection-docblock": "<3.2.2",
|
|
||||||
"phpdocumentor/type-resolver": "<1.4.0",
|
|
||||||
"symfony/dependency-injection": "<5.4",
|
|
||||||
"symfony/property-access": "<5.4",
|
|
||||||
"symfony/property-info": "<5.4.24|>=6,<6.2.11",
|
|
||||||
"symfony/uid": "<5.4",
|
|
||||||
"symfony/yaml": "<5.4"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"doctrine/annotations": "^1.12|^2",
|
|
||||||
"phpdocumentor/reflection-docblock": "^3.2|^4.0|^5.0",
|
|
||||||
"symfony/cache": "^5.4|^6.0",
|
|
||||||
"symfony/config": "^5.4|^6.0",
|
|
||||||
"symfony/console": "^5.4|^6.0",
|
|
||||||
"symfony/dependency-injection": "^5.4|^6.0",
|
|
||||||
"symfony/error-handler": "^5.4|^6.0",
|
|
||||||
"symfony/filesystem": "^5.4|^6.0",
|
|
||||||
"symfony/form": "^5.4|^6.0",
|
|
||||||
"symfony/http-foundation": "^5.4|^6.0",
|
|
||||||
"symfony/http-kernel": "^5.4|^6.0",
|
|
||||||
"symfony/mime": "^5.4|^6.0",
|
|
||||||
"symfony/property-access": "^5.4|^6.0",
|
|
||||||
"symfony/property-info": "^5.4.24|^6.2.11",
|
|
||||||
"symfony/uid": "^5.4|^6.0",
|
|
||||||
"symfony/validator": "^5.4|^6.0",
|
|
||||||
"symfony/var-dumper": "^5.4|^6.0",
|
|
||||||
"symfony/var-exporter": "^5.4|^6.0",
|
|
||||||
"symfony/yaml": "^5.4|^6.0"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Symfony\\Component\\Serializer\\": ""
|
|
||||||
},
|
|
||||||
"exclude-from-classmap": [
|
|
||||||
"/Tests/"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Fabien Potencier",
|
|
||||||
"email": "fabien@symfony.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Symfony Community",
|
|
||||||
"homepage": "https://symfony.com/contributors"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Handles serializing and deserializing data structures, including object graphs, into array structures or other formats like XML and JSON.",
|
|
||||||
"homepage": "https://symfony.com",
|
|
||||||
"support": {
|
|
||||||
"source": "https://github.com/symfony/serializer/tree/v6.3.3"
|
|
||||||
},
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"url": "https://symfony.com/sponsor",
|
|
||||||
"type": "custom"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://github.com/fabpot",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"time": "2023-07-31T07:08:24+00:00"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "symfony/service-contracts",
|
"name": "symfony/service-contracts",
|
||||||
"version": "v3.3.0",
|
"version": "v3.3.0",
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
|
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
|
||||||
|
@ -12,6 +13,7 @@ return [
|
||||||
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
|
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
|
||||||
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
|
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
|
||||||
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
|
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
|
||||||
|
JMS\SerializerBundle\JMSSerializerBundle::class => ['all' => true],
|
||||||
Knp\Bundle\PaginatorBundle\KnpPaginatorBundle::class => ['all' => true],
|
Knp\Bundle\PaginatorBundle\KnpPaginatorBundle::class => ['all' => true],
|
||||||
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
|
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
|
||||||
];
|
];
|
||||||
|
|
30
config/packages/jms_serializer.yaml
Normal file
30
config/packages/jms_serializer.yaml
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
jms_serializer:
|
||||||
|
visitors:
|
||||||
|
xml_serialization:
|
||||||
|
format_output: '%kernel.debug%'
|
||||||
|
# metadata:
|
||||||
|
# auto_detection: false
|
||||||
|
# directories:
|
||||||
|
# any-name:
|
||||||
|
# namespace_prefix: "My\\FooBundle"
|
||||||
|
# path: "@MyFooBundle/Resources/config/serializer"
|
||||||
|
# another-name:
|
||||||
|
# namespace_prefix: "My\\BarBundle"
|
||||||
|
# path: "@MyBarBundle/Resources/config/serializer"
|
||||||
|
|
||||||
|
when@prod:
|
||||||
|
jms_serializer:
|
||||||
|
visitors:
|
||||||
|
json_serialization:
|
||||||
|
options:
|
||||||
|
- JSON_UNESCAPED_SLASHES
|
||||||
|
- JSON_PRESERVE_ZERO_FRACTION
|
||||||
|
|
||||||
|
when@dev:
|
||||||
|
jms_serializer:
|
||||||
|
visitors:
|
||||||
|
json_serialization:
|
||||||
|
options:
|
||||||
|
- JSON_PRETTY_PRINT
|
||||||
|
- JSON_UNESCAPED_SLASHES
|
||||||
|
- JSON_PRESERVE_ZERO_FRACTION
|
|
@ -0,0 +1,11 @@
|
||||||
|
Skobkin\Bundle\PointToolsBundle\DTO\Api\Auth:
|
||||||
|
exclusion_policy: none
|
||||||
|
access_type: public_method
|
||||||
|
properties:
|
||||||
|
token:
|
||||||
|
type: string
|
||||||
|
csRfToken:
|
||||||
|
type: string
|
||||||
|
serialized_name: 'csrf_token'
|
||||||
|
error:
|
||||||
|
type: string
|
|
@ -0,0 +1,23 @@
|
||||||
|
Skobkin\Bundle\PointToolsBundle\DTO\Api\Comment:
|
||||||
|
exclusion_policy: none
|
||||||
|
access_type: public_method
|
||||||
|
properties:
|
||||||
|
postId:
|
||||||
|
serialized_name: 'post_id'
|
||||||
|
type: 'Skobkin\Bundle\PointToolsBundle\DTO\Api\Post'
|
||||||
|
max_depth: 2
|
||||||
|
number:
|
||||||
|
serialized_name: 'id'
|
||||||
|
type: integer
|
||||||
|
toCommentId:
|
||||||
|
serialized_name: 'to_comment_id'
|
||||||
|
type: integer
|
||||||
|
created:
|
||||||
|
type: string
|
||||||
|
text:
|
||||||
|
type: string
|
||||||
|
author:
|
||||||
|
type: 'Skobkin\Bundle\PointToolsBundle\DTO\Api\User'
|
||||||
|
isRec:
|
||||||
|
serialized_name: 'is_rec'
|
||||||
|
type: boolean
|
|
@ -0,0 +1,10 @@
|
||||||
|
Skobkin\Bundle\PointToolsBundle\DTO\Api\MetaPost:
|
||||||
|
exclusion_policy: none
|
||||||
|
access_type: public_method
|
||||||
|
properties:
|
||||||
|
post:
|
||||||
|
type: 'Skobkin\Bundle\PointToolsBundle\DTO\Api\Post'
|
||||||
|
max_depth: 2
|
||||||
|
comments:
|
||||||
|
type: 'array<Skobkin\Bundle\PointToolsBundle\DTO\Api\Comment>'
|
||||||
|
max_depth: 2
|
|
@ -0,0 +1,25 @@
|
||||||
|
Skobkin\Bundle\PointToolsBundle\DTO\Api\Post:
|
||||||
|
exclusion_policy: none
|
||||||
|
access_type: public_method
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
#groups: []
|
||||||
|
tags:
|
||||||
|
type: 'array<string>'
|
||||||
|
files:
|
||||||
|
type: 'array<string>'
|
||||||
|
author:
|
||||||
|
type: Skobkin\Bundle\PointToolsBundle\DTO\Api\User
|
||||||
|
max_depth: 1
|
||||||
|
text:
|
||||||
|
type: string
|
||||||
|
created:
|
||||||
|
type: string
|
||||||
|
type:
|
||||||
|
type: string
|
||||||
|
private:
|
||||||
|
type: boolean
|
||||||
|
|
||||||
|
#callback_methods:
|
||||||
|
# post_deserialize: [foo, bar]
|
|
@ -0,0 +1,10 @@
|
||||||
|
Skobkin\Bundle\PointToolsBundle\DTO\Api\PostsPage:
|
||||||
|
exclusion_policy: none
|
||||||
|
access_type: public_method
|
||||||
|
properties:
|
||||||
|
posts:
|
||||||
|
type: 'array<Skobkin\Bundle\PointToolsBundle\DTO\Api\MetaPost>'
|
||||||
|
max_depth: 3
|
||||||
|
hasNext:
|
||||||
|
serialized_name: 'has_next'
|
||||||
|
type: boolean
|
|
@ -0,0 +1,49 @@
|
||||||
|
Skobkin\Bundle\PointToolsBundle\DTO\Api\User:
|
||||||
|
exclusion_policy: none
|
||||||
|
access_type: public_method
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
groups: [user_short, user_full]
|
||||||
|
login:
|
||||||
|
type: string
|
||||||
|
groups: [user_short, user_full]
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
groups: [user_short, user_full]
|
||||||
|
about:
|
||||||
|
type: string
|
||||||
|
groups: [user_full]
|
||||||
|
xmpp:
|
||||||
|
type: string
|
||||||
|
groups: [user_full]
|
||||||
|
created:
|
||||||
|
type: string
|
||||||
|
groups: [user_full]
|
||||||
|
gender:
|
||||||
|
type: boolean
|
||||||
|
groups: [user_full]
|
||||||
|
denyAnonymous:
|
||||||
|
serialized_name: 'deny_anonymous'
|
||||||
|
type: boolean
|
||||||
|
groups: [user_full]
|
||||||
|
private:
|
||||||
|
type: boolean
|
||||||
|
groups: [user_full]
|
||||||
|
birthDate:
|
||||||
|
serialized_name: 'birthdate'
|
||||||
|
type: string
|
||||||
|
groups: [user_full]
|
||||||
|
homepage:
|
||||||
|
type: string
|
||||||
|
groups: [user_full]
|
||||||
|
email:
|
||||||
|
type: string
|
||||||
|
groups: [user_full]
|
||||||
|
location:
|
||||||
|
type: string
|
||||||
|
groups: [user_full]
|
||||||
|
|
||||||
|
# TODO automatically convert string date to DateTime
|
||||||
|
#callback_methods:
|
||||||
|
# post_deserialize: [foo, bar]
|
1
old/src/PointToolsBundle/Resources/config/services.yml
Normal file
1
old/src/PointToolsBundle/Resources/config/services.yml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
services:
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Tests\Skobkin\PointToolsBundle\Service\Factory;
|
namespace Tests\Skobkin\PointToolsBundle\Service\Factory;
|
||||||
|
|
||||||
|
@ -8,8 +7,8 @@ use App\Exception\Factory\InvalidUserDataException;
|
||||||
use App\Factory\UserFactory;
|
use App\Factory\UserFactory;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use App\Entity\User;
|
use src\PointToolsBundle\Entity\User;
|
||||||
use App\Repository\UserRepository;
|
use src\PointToolsBundle\Repository\UserRepository;
|
||||||
|
|
||||||
class UserFactoryTest extends TestCase
|
class UserFactoryTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -27,8 +26,8 @@ class UserFactoryTest extends TestCase
|
||||||
{
|
{
|
||||||
$testUser = new User(
|
$testUser = new User(
|
||||||
self::LOCAL_USER_ID,
|
self::LOCAL_USER_ID,
|
||||||
self::LOCAL_USER_LOGIN,
|
|
||||||
\DateTime::createFromFormat(UserFactory::DATE_FORMAT, self::LOCAL_USER_CREATED),
|
\DateTime::createFromFormat(UserFactory::DATE_FORMAT, self::LOCAL_USER_CREATED),
|
||||||
|
self::LOCAL_USER_LOGIN,
|
||||||
self::LOCAL_USER_NAME
|
self::LOCAL_USER_NAME
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ class ImportUsersCommand extends Command
|
||||||
'CSV file path'
|
'CSV file path'
|
||||||
)
|
)
|
||||||
->addOption(
|
->addOption(
|
||||||
'dry-run',
|
'check-only',
|
||||||
null,
|
null,
|
||||||
InputOption::VALUE_NONE,
|
InputOption::VALUE_NONE,
|
||||||
'If set, command will not perform write operations in the database'
|
'If set, command will not perform write operations in the database'
|
||||||
|
@ -87,9 +87,9 @@ class ImportUsersCommand extends Command
|
||||||
|
|
||||||
$createdAt = \DateTime::createFromFormat('Y-m-d_H:i:s', $row[3]) ?: new \DateTime();
|
$createdAt = \DateTime::createFromFormat('Y-m-d_H:i:s', $row[3]) ?: new \DateTime();
|
||||||
|
|
||||||
$user = new User($row[0], $row[1], $createdAt, $row[2]);
|
$user = new User($row[0], $createdAt, $row[1], $row[2]);
|
||||||
|
|
||||||
if (!$input->getOption('dry-run')) {
|
if (!$input->getOption('check-only')) {
|
||||||
$this->em->persist($user);
|
$this->em->persist($user);
|
||||||
$this->em->flush($user);
|
$this->em->flush($user);
|
||||||
$this->em->detach($user);
|
$this->em->detach($user);
|
||||||
|
|
|
@ -50,7 +50,7 @@ class TelegramSendMessageCommand extends Command
|
||||||
try {
|
try {
|
||||||
$this->messenger->sendMessageToChat(
|
$this->messenger->sendMessageToChat(
|
||||||
(int) $input->getOption('chat-id'),
|
(int) $input->getOption('chat-id'),
|
||||||
$message,
|
$message
|
||||||
);
|
);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$io->error($e->getMessage());
|
$io->error($e->getMessage());
|
||||||
|
|
|
@ -50,7 +50,7 @@ class TelegramWebhookCommand extends Command
|
||||||
try {
|
try {
|
||||||
$this->client->setWebhook(
|
$this->client->setWebhook(
|
||||||
url: $url,
|
url: $url,
|
||||||
maxConnections: $this->telegramWebhookMaxConnections,
|
max_connections: $this->telegramWebhookMaxConnections,
|
||||||
);
|
);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$io->error(\sprintf(
|
$io->error(\sprintf(
|
||||||
|
|
|
@ -42,7 +42,7 @@ class UpdateSubscriptionsCommand extends Command
|
||||||
'If set, command will check subscribers of all service users instead of service subscribers only'
|
'If set, command will check subscribers of all service users instead of service subscribers only'
|
||||||
)
|
)
|
||||||
->addOption(
|
->addOption(
|
||||||
'dry-run',
|
'check-only',
|
||||||
null,
|
null,
|
||||||
InputOption::VALUE_NONE,
|
InputOption::VALUE_NONE,
|
||||||
'If set, command will not perform write operations in the database'
|
'If set, command will not perform write operations in the database'
|
||||||
|
@ -59,7 +59,7 @@ class UpdateSubscriptionsCommand extends Command
|
||||||
$progress = $io->createProgressBar();
|
$progress = $io->createProgressBar();
|
||||||
$progress->setFormat(ProgressBar::FORMAT_DEBUG);
|
$progress->setFormat(ProgressBar::FORMAT_DEBUG);
|
||||||
|
|
||||||
if (!$input->getOption('dry-run')) { // Beginning transaction for all changes
|
if (!$input->getOption('check-only')) { // Beginning transaction for all changes
|
||||||
$this->em->beginTransaction();
|
$this->em->beginTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ class UpdateSubscriptionsCommand extends Command
|
||||||
$progress->finish();
|
$progress->finish();
|
||||||
|
|
||||||
// Flushing all changes at once to the database
|
// Flushing all changes at once to the database
|
||||||
if (!$input->getOption('dry-run')) {
|
if (!$input->getOption('check-only')) {
|
||||||
$this->em->flush();
|
$this->em->flush();
|
||||||
$this->em->commit();
|
$this->em->commit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@ namespace App\Controller\Api;
|
||||||
use App\DTO\Api\PostsPage;
|
use App\DTO\Api\PostsPage;
|
||||||
use App\Factory\Blog\PostFactory;
|
use App\Factory\Blog\PostFactory;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use JMS\Serializer\SerializerInterface;
|
||||||
use Symfony\Component\HttpFoundation\{Request, Response};
|
use Symfony\Component\HttpFoundation\{Request, Response};
|
||||||
use Symfony\Component\Serializer\SerializerInterface;
|
|
||||||
|
|
||||||
class CrawlerController extends AbstractApiController
|
class CrawlerController extends AbstractApiController
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,18 +3,41 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\DTO\Api;
|
namespace App\DTO\Api;
|
||||||
|
|
||||||
use Symfony\Component\Serializer\Annotation\SerializedName;
|
/** TODO: Refactor to public readonly */
|
||||||
|
|
||||||
class Auth implements ValidableInterface
|
class Auth implements ValidableInterface
|
||||||
{
|
{
|
||||||
public function __construct(
|
private ?string $token;
|
||||||
#[SerializedName('token')]
|
private ?string $csRfToken;
|
||||||
public readonly ?string $token,
|
private ?string $error;
|
||||||
#[SerializedName('error')]
|
|
||||||
public readonly ?string $error,
|
public function getToken(): ?string
|
||||||
#[SerializedName('csrf_token')]
|
{
|
||||||
public readonly ?string $csRfToken,
|
return $this->token;
|
||||||
) {
|
}
|
||||||
|
|
||||||
|
public function setToken(?string $token): void
|
||||||
|
{
|
||||||
|
$this->token = $token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCsRfToken(): ?string
|
||||||
|
{
|
||||||
|
return $this->csRfToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCsRfToken(?string $csRfToken): void
|
||||||
|
{
|
||||||
|
$this->csRfToken = $csRfToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getError(): ?string
|
||||||
|
{
|
||||||
|
return $this->error;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setError(?string $error): void
|
||||||
|
{
|
||||||
|
$this->error = $error;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isValid(): bool
|
public function isValid(): bool
|
||||||
|
|
|
@ -3,26 +3,91 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\DTO\Api;
|
namespace App\DTO\Api;
|
||||||
|
|
||||||
use Symfony\Component\Serializer\Annotation\SerializedName;
|
/** TODO: Refactor to public readonly */
|
||||||
|
|
||||||
class Comment implements ValidableInterface
|
class Comment implements ValidableInterface
|
||||||
{
|
{
|
||||||
public function __construct(
|
private ?string $postId;
|
||||||
#[SerializedName('post_id')]
|
private ?int $number;
|
||||||
public readonly ?string $postId,
|
private ?int $toCommentId;
|
||||||
#[SerializedName('id')]
|
private ?string $created;
|
||||||
public readonly ?int $number,
|
private ?string $text;
|
||||||
#[SerializedName('to_comment_id')]
|
private ?User $author;
|
||||||
public readonly ?int $toCommentId,
|
private ?bool $isRec;
|
||||||
#[SerializedName('created')]
|
|
||||||
public readonly ?\DateTimeImmutable $created,
|
|
||||||
#[SerializedName('text')]
|
public function getPostId(): ?string
|
||||||
public readonly ?string $text,
|
{
|
||||||
#[SerializedName('author')]
|
return $this->postId;
|
||||||
public readonly ?User $author,
|
}
|
||||||
#[SerializedName('is_rec')]
|
|
||||||
public readonly ?bool $isRec,
|
public function setPostId(?string $postId): void
|
||||||
) {
|
{
|
||||||
|
$this->postId = $postId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNumber(): ?int
|
||||||
|
{
|
||||||
|
return $this->number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setNumber(?int $number): void
|
||||||
|
{
|
||||||
|
$this->number = $number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getToCommentId(): ?int
|
||||||
|
{
|
||||||
|
return $this->toCommentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setToCommentId(?int $toCommentId): void
|
||||||
|
{
|
||||||
|
$this->toCommentId = $toCommentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCreated(): string
|
||||||
|
{
|
||||||
|
return $this->created;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCreated(?string $created): void
|
||||||
|
{
|
||||||
|
$this->created = $created;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getText(): ?string
|
||||||
|
{
|
||||||
|
return $this->text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setText(?string $text): void
|
||||||
|
{
|
||||||
|
$this->text = $text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAuthor(): ?User
|
||||||
|
{
|
||||||
|
return $this->author;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAuthor(?User $author): void
|
||||||
|
{
|
||||||
|
$this->author = $author;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isIsRec(): ?bool
|
||||||
|
{
|
||||||
|
return $this->isRec;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIsRec(): ?bool
|
||||||
|
{
|
||||||
|
return $this->isRec;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setIsRec(?bool $isRec): void
|
||||||
|
{
|
||||||
|
$this->isRec = $isRec;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isValid(): bool
|
public function isValid(): bool
|
||||||
|
|
|
@ -3,21 +3,34 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\DTO\Api;
|
namespace App\DTO\Api;
|
||||||
|
|
||||||
use Symfony\Component\Serializer\Annotation\{MaxDepth, SerializedName};
|
/** TODO: Refactor to public readonly */
|
||||||
|
|
||||||
class MetaPost implements ValidableInterface
|
class MetaPost implements ValidableInterface
|
||||||
{
|
{
|
||||||
/**
|
private ?Post $post;
|
||||||
* @param Comment[] $comments
|
/** @var Comment[]|null */
|
||||||
*/
|
private ?array $comments;
|
||||||
public function __construct(
|
|
||||||
#[SerializedName('post')]
|
|
||||||
#[MaxDepth(2)]
|
public function getPost(): ?Post
|
||||||
public readonly ?Post $post,
|
{
|
||||||
#[SerializedName('comments')]
|
return $this->post;
|
||||||
#[MaxDepth(2)]
|
}
|
||||||
public readonly ?array $comments,
|
|
||||||
) {
|
public function setPost(?Post $post): void
|
||||||
|
{
|
||||||
|
$this->post = $post;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return Comment[]|null */
|
||||||
|
public function getComments(): ?array
|
||||||
|
{
|
||||||
|
return $this->comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @param Comment[]|null $comments */
|
||||||
|
public function setComments(?array $comments): void
|
||||||
|
{
|
||||||
|
$this->comments = $comments;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isValid(): bool
|
public function isValid(): bool
|
||||||
|
|
|
@ -3,32 +3,108 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\DTO\Api;
|
namespace App\DTO\Api;
|
||||||
|
|
||||||
use App\Enum\Blog\PostTypeEnum;
|
/** TODO: Refactor to public readonly */
|
||||||
use Symfony\Component\Serializer\Annotation\{Context, MaxDepth, SerializedName};
|
|
||||||
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
|
|
||||||
|
|
||||||
class Post implements ValidableInterface
|
class Post implements ValidableInterface
|
||||||
{
|
{
|
||||||
public function __construct(
|
private ?string $id;
|
||||||
#[SerializedName('id')]
|
/** @var string[]|null */
|
||||||
public readonly ?string $id,
|
private ?array $tags;
|
||||||
#[SerializedName('tags')]
|
/** @var string[]|null */
|
||||||
public readonly ?array $tags,
|
private ?array $files;
|
||||||
#[SerializedName('files')]
|
private ?User $author;
|
||||||
public readonly ?array $files,
|
private ?string $text;
|
||||||
#[SerializedName('author')]
|
private ?string $created;
|
||||||
#[MaxDepth(1)]
|
private ?string $type;
|
||||||
public readonly ?User $author,
|
private ?bool $private;
|
||||||
#[SerializedName('text')]
|
|
||||||
public readonly ?string $text,
|
public function getId(): ?string
|
||||||
#[SerializedName('created')]
|
{
|
||||||
#[Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d_H:i:s'])]
|
return $this->id;
|
||||||
public readonly ?\DateTimeImmutable $created,
|
}
|
||||||
#[SerializedName('type')]
|
|
||||||
public readonly ?PostTypeEnum $type,
|
public function setId(?string $id): void
|
||||||
#[SerializedName('private')]
|
{
|
||||||
public readonly ?bool $private,
|
$this->id = $id;
|
||||||
) {
|
}
|
||||||
|
|
||||||
|
/** @return string[]|null */
|
||||||
|
public function getTags(): ?array
|
||||||
|
{
|
||||||
|
return $this->tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setTags(?array $tags): void
|
||||||
|
{
|
||||||
|
$this->tags = $tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return string[]|null */
|
||||||
|
public function getFiles(): ?array
|
||||||
|
{
|
||||||
|
return $this->files;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string[]|null $files
|
||||||
|
*/
|
||||||
|
public function setFiles(?array $files): void
|
||||||
|
{
|
||||||
|
$this->files = $files;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAuthor(): ?User
|
||||||
|
{
|
||||||
|
return $this->author;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAuthor(?User $author): void
|
||||||
|
{
|
||||||
|
$this->author = $author;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getText(): ?string
|
||||||
|
{
|
||||||
|
return $this->text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setText(?string $text): void
|
||||||
|
{
|
||||||
|
$this->text = $text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCreated(): ?string
|
||||||
|
{
|
||||||
|
return $this->created;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCreated(?string $created): void
|
||||||
|
{
|
||||||
|
$this->created = $created;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getType(): ?string
|
||||||
|
{
|
||||||
|
return $this->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setType(?string $type): void
|
||||||
|
{
|
||||||
|
$this->type = $type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPrivate(): ?bool
|
||||||
|
{
|
||||||
|
return $this->private;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isPrivate(): ?bool
|
||||||
|
{
|
||||||
|
return $this->private;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPrivate(?bool $private): void
|
||||||
|
{
|
||||||
|
$this->private = $private;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isValid(): bool
|
public function isValid(): bool
|
||||||
|
|
|
@ -3,15 +3,33 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\DTO\Api;
|
namespace App\DTO\Api;
|
||||||
|
|
||||||
|
/** TODO: Refactor to public readonly */
|
||||||
class PostsPage implements ValidableInterface
|
class PostsPage implements ValidableInterface
|
||||||
{
|
{
|
||||||
/**
|
/** @var MetaPost[]|null */
|
||||||
* @param MetaPost[]|null $posts
|
private ?array $posts;
|
||||||
*/
|
private ?bool $hasNext;
|
||||||
public function __construct(
|
|
||||||
public readonly ?array $posts,
|
/** @return MetaPost[]|null */
|
||||||
public readonly ?bool $hasNext,
|
public function getPosts(): ?array
|
||||||
) {
|
{
|
||||||
|
return $this->posts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @param MetaPost[]|null $posts */
|
||||||
|
public function setPosts(?array $posts): void
|
||||||
|
{
|
||||||
|
$this->posts = $posts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHasNext(): ?bool
|
||||||
|
{
|
||||||
|
return $this->hasNext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setHasNext(?bool $hasNext): void
|
||||||
|
{
|
||||||
|
$this->hasNext = $hasNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isValid(): bool
|
public function isValid(): bool
|
||||||
|
|
|
@ -3,57 +3,166 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\DTO\Api;
|
namespace App\DTO\Api;
|
||||||
|
|
||||||
use Symfony\Component\Serializer\Annotation\{Context, Groups, SerializedName};
|
/** TODO: Refactor to public readonly */
|
||||||
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
|
|
||||||
|
|
||||||
class User implements ValidableInterface
|
class User implements ValidableInterface
|
||||||
{
|
{
|
||||||
public function __construct(
|
private ?string $id;
|
||||||
#[SerializedName('id')]
|
private ?string $login;
|
||||||
#[Groups(['user_short', 'user_full'])]
|
private ?string $name;
|
||||||
public readonly ?int $id,
|
private ?string $about;
|
||||||
#[SerializedName('login')]
|
private ?string $xmpp;
|
||||||
#[Groups(['user_short', 'user_full'])]
|
private ?string $created;
|
||||||
public readonly ?string $login,
|
private ?bool $gender;
|
||||||
#[SerializedName('name')]
|
private ?bool $denyAnonymous;
|
||||||
#[Groups(['user_short', 'user_full'])]
|
private ?bool $private;
|
||||||
public readonly ?string $name,
|
private ?string $birthDate;
|
||||||
#[SerializedName('about')]
|
private ?string $homepage;
|
||||||
#[Groups(['user_full'])]
|
private ?string $email;
|
||||||
public readonly ?string $about,
|
private ?string $location;
|
||||||
#[SerializedName('xmpp')]
|
private ?string $error;
|
||||||
#[Groups(['user_full'])]
|
|
||||||
public readonly ?string $xmpp,
|
public function getId(): ?string
|
||||||
#[SerializedName('created')]
|
{
|
||||||
#[Groups(['user_full'])]
|
return $this->id;
|
||||||
#[Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d_H:i:s'])]
|
}
|
||||||
public readonly ?\DateTimeImmutable $created,
|
|
||||||
#[SerializedName('gender')]
|
public function setId(?string $id): void
|
||||||
#[Groups(['user_full'])]
|
{
|
||||||
public readonly ?bool $gender,
|
$this->id = $id;
|
||||||
#[SerializedName('deny_anonymous')]
|
}
|
||||||
#[Groups(['user_full'])]
|
|
||||||
public readonly ?bool $denyAnonymous,
|
public function getLogin(): ?string
|
||||||
#[SerializedName('private')]
|
{
|
||||||
#[Groups(['user_full'])]
|
return $this->login;
|
||||||
public readonly ?bool $private,
|
}
|
||||||
#[SerializedName('birthdate')]
|
|
||||||
#[Groups(['user_full'])]
|
public function setLogin(?string $login): void
|
||||||
public readonly ?string $birthDate,
|
{
|
||||||
#[SerializedName('homepage')]
|
$this->login = $login;
|
||||||
#[Groups(['user_full'])]
|
}
|
||||||
public readonly ?string $homepage,
|
|
||||||
#[SerializedName('email')]
|
public function getName(): ?string
|
||||||
#[Groups(['user_full'])]
|
{
|
||||||
public readonly ?string $email,
|
return $this->name;
|
||||||
#[SerializedName('location')]
|
}
|
||||||
#[Groups(['user_full'])]
|
|
||||||
public readonly ?string $location,
|
public function setName(?string $name): void
|
||||||
) {
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAbout(): ?string
|
||||||
|
{
|
||||||
|
return $this->about;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAbout(?string $about): void
|
||||||
|
{
|
||||||
|
$this->about = $about;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getXmpp(): ?string
|
||||||
|
{
|
||||||
|
return $this->xmpp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setXmpp(?string $xmpp): void
|
||||||
|
{
|
||||||
|
$this->xmpp = $xmpp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCreated(): ?string
|
||||||
|
{
|
||||||
|
return $this->created;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCreated(?string $created): void
|
||||||
|
{
|
||||||
|
$this->created = $created;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getGender(): ?bool
|
||||||
|
{
|
||||||
|
return $this->gender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setGender(?bool $gender): void
|
||||||
|
{
|
||||||
|
$this->gender = $gender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDenyAnonymous(): ?bool
|
||||||
|
{
|
||||||
|
return $this->denyAnonymous;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDenyAnonymous(?bool $denyAnonymous): void
|
||||||
|
{
|
||||||
|
$this->denyAnonymous = $denyAnonymous;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPrivate(): ?bool
|
||||||
|
{
|
||||||
|
return $this->private;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPrivate(?bool $private): void
|
||||||
|
{
|
||||||
|
$this->private = $private;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBirthDate(): ?string
|
||||||
|
{
|
||||||
|
return $this->birthDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setBirthDate(?string $birthDate): void
|
||||||
|
{
|
||||||
|
$this->birthDate = $birthDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHomepage(): ?string
|
||||||
|
{
|
||||||
|
return $this->homepage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setHomepage(?string $homepage): void
|
||||||
|
{
|
||||||
|
$this->homepage = $homepage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEmail(): ?string
|
||||||
|
{
|
||||||
|
return $this->email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setEmail(?string $email): void
|
||||||
|
{
|
||||||
|
$this->email = $email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLocation(): ?string
|
||||||
|
{
|
||||||
|
return $this->location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setLocation(?string $location): void
|
||||||
|
{
|
||||||
|
$this->location = $location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getError(): ?string
|
||||||
|
{
|
||||||
|
return $this->error;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setError(?string $error): void
|
||||||
|
{
|
||||||
|
$this->error = $error;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isValid(): bool
|
public function isValid(): bool
|
||||||
{
|
{
|
||||||
return null !== $this->id && null !== $this->login;
|
return null === $this->error && null !== $this->id && null !== $this->login;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\DTO\Api;
|
namespace App\DTO\Api;
|
||||||
|
|
||||||
/** @deprecated Use Symfony Validator instead */
|
|
||||||
interface ValidableInterface
|
interface ValidableInterface
|
||||||
{
|
{
|
||||||
/** @deprecated Use Symfony Validator instead */
|
|
||||||
public function isValid(): bool;
|
public function isValid(): bool;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ class LoadUserData extends Fixture implements OrderedFixtureInterface
|
||||||
public function load(ObjectManager $om)
|
public function load(ObjectManager $om)
|
||||||
{
|
{
|
||||||
foreach ($this->users as $userData) {
|
foreach ($this->users as $userData) {
|
||||||
$user = new User($userData['id'], $userData['login'], new \DateTime(), $userData['name']);
|
$user = new User($userData['id'], new \DateTime(), $userData['login'], $userData['name']);
|
||||||
$user->updatePrivacy(!$userData['private'], $userData['whitelist-only']);
|
$user->updatePrivacy(!$userData['private'], $userData['whitelist-only']);
|
||||||
|
|
||||||
$om->persist($user);
|
$om->persist($user);
|
||||||
|
|
|
@ -22,7 +22,7 @@ class Post
|
||||||
private string $text;
|
private string $text;
|
||||||
|
|
||||||
#[ORM\Column(name: 'created_at', type: 'datetime')]
|
#[ORM\Column(name: 'created_at', type: 'datetime')]
|
||||||
private \DateTimeImmutable $createdAt;
|
private \DateTime $createdAt;
|
||||||
|
|
||||||
#[ORM\Column(name: 'updated_at', type: 'datetime', nullable: true)]
|
#[ORM\Column(name: 'updated_at', type: 'datetime', nullable: true)]
|
||||||
private ?\DateTime $updatedAt;
|
private ?\DateTime $updatedAt;
|
||||||
|
@ -56,7 +56,7 @@ class Post
|
||||||
private Collection $comments;
|
private Collection $comments;
|
||||||
|
|
||||||
|
|
||||||
public function __construct(string $id, User $author, \DateTimeImmutable $createdAt, PostTypeEnum $type)
|
public function __construct(string $id, User $author, \DateTime $createdAt, PostTypeEnum $type)
|
||||||
{
|
{
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$this->author = $author;
|
$this->author = $author;
|
||||||
|
@ -91,7 +91,7 @@ class Post
|
||||||
return $this->text;
|
return $this->text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCreatedAt(): \DateTimeImmutable
|
public function getCreatedAt(): \DateTime
|
||||||
{
|
{
|
||||||
return $this->createdAt;
|
return $this->createdAt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,8 +54,8 @@ class User
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
int $id,
|
int $id,
|
||||||
string $login,
|
|
||||||
\DateTime $createdAt = null,
|
\DateTime $createdAt = null,
|
||||||
|
string $login = null,
|
||||||
string $name = null
|
string $name = null
|
||||||
) {
|
) {
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
|
|
|
@ -8,7 +8,7 @@ use Psr\Log\LoggerInterface;
|
||||||
abstract class AbstractFactory
|
abstract class AbstractFactory
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
protected readonly LoggerInterface $logger,
|
protected LoggerInterface $logger,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
21
src/Factory/Blog/CommentFactory.php
Normal file
21
src/Factory/Blog/CommentFactory.php
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Factory\Blog;
|
||||||
|
|
||||||
|
use App\Factory\{AbstractFactory};
|
||||||
|
use App\Factory\UserFactory;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
use App\Repository\Blog\{CommentRepository, PostRepository};
|
||||||
|
|
||||||
|
class CommentFactory extends AbstractFactory
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
LoggerInterface $logger,
|
||||||
|
private readonly CommentRepository $commentRepository,
|
||||||
|
private readonly PostRepository $postRepository,
|
||||||
|
private readonly UserFactory $userFactory,
|
||||||
|
) {
|
||||||
|
parent::__construct($logger);
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,7 +4,8 @@ declare(strict_types=1);
|
||||||
namespace App\Factory\Blog;
|
namespace App\Factory\Blog;
|
||||||
|
|
||||||
use App\Enum\Blog\PostTypeEnum;
|
use App\Enum\Blog\PostTypeEnum;
|
||||||
use App\Factory\{AbstractFactory, UserFactory};
|
use App\Factory\AbstractFactory;
|
||||||
|
use App\Factory\UserFactory;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use App\DTO\Api\{MetaPost, PostsPage, Post as PostDTO};
|
use App\DTO\Api\{MetaPost, PostsPage, Post as PostDTO};
|
||||||
|
@ -22,6 +23,7 @@ class PostFactory extends AbstractFactory
|
||||||
private readonly PostRepository $postRepository,
|
private readonly PostRepository $postRepository,
|
||||||
private readonly UserFactory $userFactory,
|
private readonly UserFactory $userFactory,
|
||||||
private readonly FileFactory $fileFactory,
|
private readonly FileFactory $fileFactory,
|
||||||
|
private readonly CommentFactory $commentFactory,
|
||||||
private readonly TagFactory $tagFactory,
|
private readonly TagFactory $tagFactory,
|
||||||
) {
|
) {
|
||||||
parent::__construct($logger);
|
parent::__construct($logger);
|
||||||
|
@ -38,10 +40,9 @@ class PostFactory extends AbstractFactory
|
||||||
|
|
||||||
$hasNew = false;
|
$hasNew = false;
|
||||||
|
|
||||||
/** @var MetaPost $postData */
|
foreach ((array) $page->getPosts() as $postData) {
|
||||||
foreach ($page->posts ?? [] as $postData) {
|
|
||||||
try {
|
try {
|
||||||
if (null === $this->postRepository->find($postData->post->id)) {
|
if (null === $this->postRepository->find($postData->getPost()->getId())) {
|
||||||
$hasNew = true;
|
$hasNew = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +50,7 @@ class PostFactory extends AbstractFactory
|
||||||
$posts[] = $post;
|
$posts[] = $post;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->logger->error('Error while processing post DTO', [
|
$this->logger->error('Error while processing post DTO', [
|
||||||
'post_id' => $postData->post->id,
|
'post_id' => $postData->getPost()->getId(),
|
||||||
'exception' => get_class($e),
|
'exception' => get_class($e),
|
||||||
'message' => $e->getMessage(),
|
'message' => $e->getMessage(),
|
||||||
'file' => $e->getFile(),
|
'file' => $e->getFile(),
|
||||||
|
@ -81,10 +82,10 @@ class PostFactory extends AbstractFactory
|
||||||
throw new InvalidDataException('Invalid post data');
|
throw new InvalidDataException('Invalid post data');
|
||||||
}
|
}
|
||||||
|
|
||||||
$postData = $metaPost->post;
|
$postData = $metaPost->getPost();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$author = $this->userFactory->findOrCreateFromDTO($postData->author);
|
$author = $this->userFactory->findOrCreateFromDTO($metaPost->getPost()->getAuthor());
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->logger->error('Error while creating user from DTO');
|
$this->logger->error('Error while creating user from DTO');
|
||||||
throw $e;
|
throw $e;
|
||||||
|
@ -93,14 +94,14 @@ class PostFactory extends AbstractFactory
|
||||||
$post = $this->findOrCreateFromDto($postData, $author);
|
$post = $this->findOrCreateFromDto($postData, $author);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->updatePostTags($post, $postData->tags ?? []);
|
$this->updatePostTags($post, $postData->getTags() ?: []);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->logger->error('Error while updating post tags');
|
$this->logger->error('Error while updating post tags');
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->updatePostFiles($post, $postData->files ?? []);
|
$this->updatePostFiles($post, $postData->getFiles() ?: []);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->logger->error('Error while updating post files');
|
$this->logger->error('Error while updating post files');
|
||||||
throw $e;
|
throw $e;
|
||||||
|
@ -111,19 +112,20 @@ class PostFactory extends AbstractFactory
|
||||||
|
|
||||||
private function findOrCreateFromDto(PostDTO $postData, User $author): Post
|
private function findOrCreateFromDto(PostDTO $postData, User $author): Post
|
||||||
{
|
{
|
||||||
if (null === ($post = $this->postRepository->find($postData->id))) {
|
if (null === ($post = $this->postRepository->find($postData->getId()))) {
|
||||||
|
// Creating new post
|
||||||
$post = new Post(
|
$post = new Post(
|
||||||
$postData->id,
|
$postData->getId(),
|
||||||
$author,
|
$author,
|
||||||
$postData->created,
|
new \DateTime($postData->getCreated()),
|
||||||
$postData->type ?? PostTypeEnum::Post,
|
PostTypeEnum::tryFrom($postData->getType()) ?? PostTypeEnum::Post,
|
||||||
);
|
);
|
||||||
$this->postRepository->save($post);
|
$this->postRepository->save($post);
|
||||||
}
|
}
|
||||||
|
|
||||||
$post
|
$post
|
||||||
->setText($postData->text)
|
->setText($postData->getText())
|
||||||
->setPrivate($postData->private)
|
->setPrivate($postData->getPrivate())
|
||||||
;
|
;
|
||||||
|
|
||||||
return $post;
|
return $post;
|
||||||
|
|
|
@ -29,19 +29,18 @@ class UserFactory extends AbstractFactory
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
if (null === ($user = $this->userRepository->find($userData->id))) {
|
if (null === ($user = $this->userRepository->find($userData->getId()))) {
|
||||||
$user = new User(
|
$user = new User(
|
||||||
$userData->id,
|
(int) $userData->getId(),
|
||||||
$userData->login,
|
\DateTime::createFromFormat('Y-m-d_H:i:s', $userData->getCreated()) ?: new \DateTime()
|
||||||
$userData->created,
|
|
||||||
);
|
);
|
||||||
$this->userRepository->save($user);
|
$this->userRepository->add($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
$user->updateLoginAndName($userData->login, $userData->name);
|
$user->updateLoginAndName($userData->getLogin(), $userData->getName());
|
||||||
|
|
||||||
if (null !== $userData->denyAnonymous && null !== $userData->private) {
|
if (null !== $userData->getDenyAnonymous() && null !== $userData->getPrivate()) {
|
||||||
$user->updatePrivacy(!$userData->denyAnonymous, $userData->private);
|
$user->updatePrivacy(!$userData->getDenyAnonymous(), $userData->getPrivate());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
|
|
|
@ -9,14 +9,14 @@ use App\Exception\Api\{ApiException,
|
||||||
NotFoundException,
|
NotFoundException,
|
||||||
UnauthorizedException,
|
UnauthorizedException,
|
||||||
ServerProblemException};
|
ServerProblemException};
|
||||||
|
use JMS\Serializer\SerializerInterface;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
|
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
|
||||||
use Symfony\Component\Serializer\Context\Normalizer\ObjectNormalizerContextBuilder;
|
|
||||||
use Symfony\Component\Serializer\SerializerInterface;
|
|
||||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||||
use Symfony\Contracts\HttpClient\{HttpClientInterface, ResponseInterface};
|
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||||
|
use Symfony\Contracts\HttpClient\ResponseInterface;
|
||||||
|
|
||||||
abstract class AbstractApi
|
class AbstractApi
|
||||||
{
|
{
|
||||||
protected HttpClientInterface $client;
|
protected HttpClientInterface $client;
|
||||||
// TODO: check if these are still needed
|
// TODO: check if these are still needed
|
||||||
|
@ -32,24 +32,24 @@ abstract class AbstractApi
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Make GET request and return DTO objects */
|
/** Make GET request and return DTO objects */
|
||||||
public function getGetJsonData(string $path, array $parameters = [], string $type, array $groups = []): array|object|null
|
public function getGetJsonData(string $path, array $parameters = [], string $type, DeserializationContext $context = null): array|object|null
|
||||||
{
|
{
|
||||||
return $this->serializer->deserialize(
|
return $this->serializer->deserialize(
|
||||||
$this->getGetResponseBody($path, $parameters),
|
$this->getGetResponseBody($path, $parameters),
|
||||||
$type,
|
$type,
|
||||||
'json',
|
'json',
|
||||||
$this->createContext($groups),
|
$context
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Make POST request and return DTO objects */
|
/** Make POST request and return DTO objects */
|
||||||
public function getPostJsonData(string $path, array $parameters = [], string $type, array $groups = []): array|object|null
|
public function getPostJsonData(string $path, array $parameters = [], string $type, DeserializationContext $context = null): array|object|null
|
||||||
{
|
{
|
||||||
return $this->serializer->deserialize(
|
return $this->serializer->deserialize(
|
||||||
$this->getPostResponseBody($path, $parameters),
|
$this->getPostResponseBody($path, $parameters),
|
||||||
$type,
|
$type,
|
||||||
'json',
|
'json',
|
||||||
$this->createContext($groups)
|
$context
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,13 +65,6 @@ abstract class AbstractApi
|
||||||
return $this->sendPostRequest($path, $parameters)->getContent();
|
return $this->sendPostRequest($path, $parameters)->getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createContext(array $groups): array
|
|
||||||
{
|
|
||||||
return (new ObjectNormalizerContextBuilder())
|
|
||||||
->withGroups($groups)
|
|
||||||
->toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function sendGetRequest(string $path, array $parameters = []): ResponseInterface
|
private function sendGetRequest(string $path, array $parameters = []): ResponseInterface
|
||||||
{
|
{
|
||||||
$this->logger->debug('Sending GET request', ['path' => $path, 'parameters' => $parameters]);
|
$this->logger->debug('Sending GET request', ['path' => $path, 'parameters' => $parameters]);
|
||||||
|
@ -110,7 +103,7 @@ abstract class AbstractApi
|
||||||
// Temporary fix until @arts fixes this bug
|
// Temporary fix until @arts fixes this bug
|
||||||
if ('{"error": "UserNotFound"}' === $response->getContent()) {
|
if ('{"error": "UserNotFound"}' === $response->getContent()) {
|
||||||
throw new NotFoundException('Not found', SymfonyResponse::HTTP_NOT_FOUND);
|
throw new NotFoundException('Not found', SymfonyResponse::HTTP_NOT_FOUND);
|
||||||
} elseif ('{"message": "Forbidden", "code": 403, "error": "Forbidden"}' === (string) $response->getContent()) {
|
} elseif ('{"message": "Forbidden", "code": 403, "error": "Forbidden"}' === (string) $response->getBody()) {
|
||||||
throw new ForbiddenException('Forbidden', SymfonyResponse::HTTP_FORBIDDEN);
|
throw new ForbiddenException('Forbidden', SymfonyResponse::HTTP_FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
22
src/Service/Api/PostApi.php
Normal file
22
src/Service/Api/PostApi.php
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Service\Api;
|
||||||
|
|
||||||
|
use JMS\Serializer\SerializerInterface;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
use App\Factory\Blog\PostFactory;
|
||||||
|
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||||
|
|
||||||
|
/** Basic Point.im user API functions from /api/post */
|
||||||
|
class PostApi extends AbstractApi
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
HttpClientInterface $pointApiClient,
|
||||||
|
SerializerInterface $serializer,
|
||||||
|
LoggerInterface $logger,
|
||||||
|
private readonly PostFactory $postFactory,
|
||||||
|
) {
|
||||||
|
parent::__construct($pointApiClient, $logger, $serializer);
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,8 +11,8 @@ use App\Exception\Api\{ForbiddenException,
|
||||||
UserNotFoundException
|
UserNotFoundException
|
||||||
};
|
};
|
||||||
use App\Factory\UserFactory;
|
use App\Factory\UserFactory;
|
||||||
|
use JMS\Serializer\{DeserializationContext, SerializerInterface};
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\Serializer\SerializerInterface;
|
|
||||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||||
|
|
||||||
/** Basic Point.im user API functions from /api/user/* */
|
/** Basic Point.im user API functions from /api/user/* */
|
||||||
|
@ -89,8 +89,8 @@ class UserApi extends AbstractApi
|
||||||
$usersList = $this->getGetJsonData(
|
$usersList = $this->getGetJsonData(
|
||||||
self::PREFIX.urlencode($login).'/subscribers',
|
self::PREFIX.urlencode($login).'/subscribers',
|
||||||
[],
|
[],
|
||||||
UserDTO::class.'[]',
|
'array<'.UserDTO::class.'>',
|
||||||
['user_short'],
|
DeserializationContext::create()->setGroups(['user_short']),
|
||||||
);
|
);
|
||||||
} catch (NotFoundException $e) {
|
} catch (NotFoundException $e) {
|
||||||
throw new UserNotFoundException('User not found', 0, $e, null, $login);
|
throw new UserNotFoundException('User not found', 0, $e, null, $login);
|
||||||
|
@ -108,8 +108,8 @@ class UserApi extends AbstractApi
|
||||||
$usersList = $this->getGetJsonData(
|
$usersList = $this->getGetJsonData(
|
||||||
self::PREFIX.'id/'.$id.'/subscribers',
|
self::PREFIX.'id/'.$id.'/subscribers',
|
||||||
[],
|
[],
|
||||||
UserDTO::class.'[]',
|
'array<'.UserDTO::class.'>',
|
||||||
['user_short'],
|
DeserializationContext::create()->setGroups(['user_short']),
|
||||||
);
|
);
|
||||||
} catch (NotFoundException $e) {
|
} catch (NotFoundException $e) {
|
||||||
throw new UserNotFoundException('User not found', 0, $e, $id);
|
throw new UserNotFoundException('User not found', 0, $e, $id);
|
||||||
|
@ -128,7 +128,7 @@ class UserApi extends AbstractApi
|
||||||
self::PREFIX.'login/'.urlencode($login),
|
self::PREFIX.'login/'.urlencode($login),
|
||||||
[],
|
[],
|
||||||
UserDTO::class,
|
UserDTO::class,
|
||||||
['user_full'],
|
DeserializationContext::create()->setGroups(['user_full']),
|
||||||
);
|
);
|
||||||
} catch (NotFoundException $e) {
|
} catch (NotFoundException $e) {
|
||||||
throw new UserNotFoundException('User not found', 0, $e, null, $login);
|
throw new UserNotFoundException('User not found', 0, $e, null, $login);
|
||||||
|
@ -147,7 +147,7 @@ class UserApi extends AbstractApi
|
||||||
self::PREFIX.'id/'.$id,
|
self::PREFIX.'id/'.$id,
|
||||||
[],
|
[],
|
||||||
UserDTO::class,
|
UserDTO::class,
|
||||||
['user_full'],
|
DeserializationContext::create()->setGroups(['user_full']),
|
||||||
);
|
);
|
||||||
} catch (NotFoundException $e) {
|
} catch (NotFoundException $e) {
|
||||||
throw new UserNotFoundException('User not found', 0, $e, $id);
|
throw new UserNotFoundException('User not found', 0, $e, $id);
|
||||||
|
|
12
symfony.lock
12
symfony.lock
|
@ -47,6 +47,18 @@
|
||||||
"migrations/.gitignore"
|
"migrations/.gitignore"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"jms/serializer-bundle": {
|
||||||
|
"version": "5.2",
|
||||||
|
"recipe": {
|
||||||
|
"repo": "github.com/symfony/recipes-contrib",
|
||||||
|
"branch": "main",
|
||||||
|
"version": "4.0",
|
||||||
|
"ref": "cc04e10cf7171525b50c18b36004edf64cb478be"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"config/packages/jms_serializer.yaml"
|
||||||
|
]
|
||||||
|
},
|
||||||
"knplabs/knp-paginator-bundle": {
|
"knplabs/knp-paginator-bundle": {
|
||||||
"version": "v6.2.0"
|
"version": "v6.2.0"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue