Bläddra i källkod

refactoring

master
Daniel 1 år sedan
förälder
incheckning
e80990bd2d
8 ändrade filer med 72 tillägg och 3 borttagningar
  1. +1
    -1
      export/openapi.json
  2. +53
    -0
      export/openapi.yaml
  3. +1
    -1
      src/ApiResource/PartnerProductApi.php
  4. +2
    -1
      src/ApiResource/PostingApi.php
  5. +3
    -0
      src/ApiResource/UserApi.php
  6. +1
    -0
      src/EventListener/AuthenticationSuccessListener.php
  7. +8
    -0
      src/Mapper/PostingEntityToApiMapper.php
  8. +3
    -0
      src/Mapper/UserEntityToApiMapper.php

+ 1
- 1
export/openapi.json
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 53
- 0
export/openapi.yaml Visa fil

@@ -1633,6 +1633,18 @@ paths:
style: form
explode: true
allowReserved: false
-
name: product.name
in: query
description: ''
required: false
deprecated: false
allowEmptyValue: true
schema:
type: string
style: form
explode: false
allowReserved: false
deprecated: false
post:
operationId: api_partner_products_post
@@ -2185,6 +2197,32 @@ paths:
style: form
explode: true
allowReserved: false
-
name: owner
in: query
description: ''
required: false
deprecated: false
allowEmptyValue: true
schema:
type: string
style: form
explode: false
allowReserved: false
-
name: 'owner[]'
in: query
description: ''
required: false
deprecated: false
allowEmptyValue: true
schema:
type: array
items:
type: string
style: form
explode: true
allowReserved: false
-
name: 'exists[contact]'
in: query
@@ -6816,6 +6854,11 @@ components:
- 'null'
format: iri-reference
example: 'https://example.com/'
imageUrl:
readOnly: true
type:
- string
- 'null'
password:
writeOnly: true
description: 'The plaintext password when being set or changed.'
@@ -6869,6 +6912,11 @@ components:
- 'null'
format: iri-reference
example: 'https://example.com/'
imageUrl:
readOnly: true
type:
- string
- 'null'
password:
writeOnly: true
description: 'The plaintext password when being set or changed.'
@@ -6936,6 +6984,11 @@ components:
- 'null'
format: iri-reference
example: 'https://example.com/'
imageUrl:
readOnly: true
type:
- string
- 'null'
password:
writeOnly: true
description: 'The plaintext password when being set or changed.'


+ 1
- 1
src/ApiResource/PartnerProductApi.php Visa fil

@@ -42,7 +42,7 @@ use Symfony\Component\Validator\Constraints\NotBlank;
processor: EntityClassDtoStateProcessor::class,
stateOptions: new Options(entityClass: PartnerProduct::class),
)]
#[ApiFilter(SearchFilter::class, properties: ['partner' => 'exact', 'product' => 'exact'])]
#[ApiFilter(SearchFilter::class, properties: ['partner' => 'exact', 'product' => 'exact', 'product.name' => 'ipartial'])]
class PartnerProductApi
{
#[ApiProperty(readable: false, writable: false, identifier: true)]


+ 2
- 1
src/ApiResource/PostingApi.php Visa fil

@@ -57,7 +57,8 @@ use Symfony\Component\Validator\Constraints\NotBlank;
#[ApiFilter(SearchFilter::class, properties: [
'partner' => 'exact',
'contact' => 'exact',
'sale' => 'exact'
'sale' => 'exact',
'owner' => 'exact'
])]
#[ApiFilter(ExistsFilter::class, properties: [
'contact',


+ 3
- 0
src/ApiResource/UserApi.php Visa fil

@@ -64,6 +64,9 @@ class UserApi

public ?MediaObject $image = null;

#[ApiProperty(writable: false)]
public ?string $imageUrl = null;

/**
* The plaintext password when being set or changed.
*/


+ 1
- 0
src/EventListener/AuthenticationSuccessListener.php Visa fil

@@ -46,6 +46,7 @@ class AuthenticationSuccessListener
$data['firstName'] = $user->getFirstName();
$data['lastName'] = $user->getLastName();
$data['roles'] = $user->getRoles();
$data['userResource'] = $userApi;
$event->setData($data);
}
}

+ 8
- 0
src/Mapper/PostingEntityToApiMapper.php Visa fil

@@ -6,6 +6,7 @@ use App\ApiResource\CommentApi;
use App\ApiResource\ContactApi;
use App\ApiResource\PartnerApi;
use App\ApiResource\ProductApi;
use App\ApiResource\SaleApi;
use App\ApiResource\UserApi;
use App\ApiResource\PostingApi;
use App\Entity\Comment;
@@ -65,6 +66,13 @@ class PostingEntityToApiMapper implements MapperInterface
]);
}

$dto->sale = null;
if ($entity->getSale() !== null) {
$dto->sale = $this->microMapper->map($entity->getSale(), SaleApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
}

$dto->comments = array_map(function(Comment $comment) {
return $this->microMapper->map($comment, CommentApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,


+ 3
- 0
src/Mapper/UserEntityToApiMapper.php Visa fil

@@ -6,6 +6,7 @@ use App\ApiResource\UserApi;
use App\ApiResource\PostingApi;
use App\Entity\User;
use App\Entity\Posting;
use App\Service\FileUrlService;
use Symfonycasts\MicroMapper\AsMapper;
use Symfonycasts\MicroMapper\MapperInterface;
use Symfonycasts\MicroMapper\MicroMapperInterface;
@@ -15,6 +16,7 @@ class UserEntityToApiMapper implements MapperInterface
{
public function __construct(
private MicroMapperInterface $microMapper,
private FileUrlService $fileUrlService
)
{
}
@@ -41,6 +43,7 @@ class UserEntityToApiMapper implements MapperInterface
$dto->firstName = $entity->getFirstName();
$dto->lastName = $entity->getLastName();
$dto->image = $entity->getImage();
$dto->imageUrl = $this->fileUrlService->getFileUrl($entity->getImage());

return $dto;
}


Laddar…
Avbryt
Spara