Procházet zdrojové kódy

mapped image url

master
Daniel před 2 roky
rodič
revize
1b2c284535
6 změnil soubory, kde provedl 93 přidání a 49 odebrání
  1. +84
    -45
      openapi.yaml
  2. +3
    -0
      src/ApiResource/ContactApi.php
  3. +2
    -0
      src/ApiResource/PartnerApi.php
  4. +1
    -0
      src/Mapper/ContactEntityToApiMapper.php
  5. +3
    -3
      src/Mapper/PartnerEntityToApiMapper.php
  6. +0
    -1
      src/Serializer/MediaObjectNormalizer.php

+ 84
- 45
openapi.yaml Zobrazit soubor

@@ -1119,11 +1119,12 @@ components:
- string - string
- 'null' - 'null'
partner: partner:
anyOf:
-
$ref: '#/components/schemas/Partner'
-
type: 'null'
'owl:maxCardinality': 1
type:
- string
- 'null'
format: iri-reference
example: 'https://example.com/'
birthday: birthday:
type: type:
- string - string
@@ -1136,6 +1137,10 @@ components:
- 'null' - 'null'
format: iri-reference format: iri-reference
example: 'https://example.com/' example: 'https://example.com/'
imageUrl:
type:
- string
- 'null'
position: position:
type: type:
- string - string
@@ -1179,11 +1184,12 @@ components:
- string - string
- 'null' - 'null'
partner: partner:
anyOf:
-
$ref: '#/components/schemas/Partner.jsonhal'
-
type: 'null'
'owl:maxCardinality': 1
type:
- string
- 'null'
format: iri-reference
example: 'https://example.com/'
birthday: birthday:
type: type:
- string - string
@@ -1196,6 +1202,10 @@ components:
- 'null' - 'null'
format: iri-reference format: iri-reference
example: 'https://example.com/' example: 'https://example.com/'
imageUrl:
type:
- string
- 'null'
position: position:
type: type:
- string - string
@@ -1253,11 +1263,12 @@ components:
- string - string
- 'null' - 'null'
partner: partner:
anyOf:
-
$ref: '#/components/schemas/Partner.jsonld'
-
type: 'null'
'owl:maxCardinality': 1
type:
- string
- 'null'
format: iri-reference
example: 'https://example.com/'
birthday: birthday:
type: type:
- string - string
@@ -1270,6 +1281,10 @@ components:
- 'null' - 'null'
format: iri-reference format: iri-reference
example: 'https://example.com/' example: 'https://example.com/'
imageUrl:
type:
- string
- 'null'
position: position:
type: type:
- string - string
@@ -1362,10 +1377,10 @@ components:
type: object type: object
description: '' description: ''
deprecated: false deprecated: false
required:
- name
- type
properties: properties:
id:
readOnly: true
type: integer
name: name:
type: string type: string
type: type:
@@ -1398,13 +1413,6 @@ components:
type: type:
- string - string
- 'null' - 'null'
createdAt:
type: string
format: date-time
contacts:
type: array
items:
$ref: '#/components/schemas/Contact'
logo: logo:
'owl:maxCardinality': 1 'owl:maxCardinality': 1
type: type:
@@ -1412,10 +1420,28 @@ components:
- 'null' - 'null'
format: iri-reference format: iri-reference
example: 'https://example.com/' example: 'https://example.com/'
logoUrl:
type:
- string
- 'null'
createdAt:
type:
- string
- 'null'
format: date-time
contacts:
type: array
items:
type: string
format: iri-reference
example: 'https://example.com/'
Partner.jsonhal: Partner.jsonhal:
type: object type: object
description: '' description: ''
deprecated: false deprecated: false
required:
- name
- type
properties: properties:
_links: _links:
type: object type: object
@@ -1426,9 +1452,6 @@ components:
href: href:
type: string type: string
format: iri-reference format: iri-reference
id:
readOnly: true
type: integer
name: name:
type: string type: string
type: type:
@@ -1461,13 +1484,6 @@ components:
type: type:
- string - string
- 'null' - 'null'
createdAt:
type: string
format: date-time
contacts:
type: array
items:
$ref: '#/components/schemas/Contact.jsonhal'
logo: logo:
'owl:maxCardinality': 1 'owl:maxCardinality': 1
type: type:
@@ -1475,10 +1491,28 @@ components:
- 'null' - 'null'
format: iri-reference format: iri-reference
example: 'https://example.com/' example: 'https://example.com/'
logoUrl:
type:
- string
- 'null'
createdAt:
type:
- string
- 'null'
format: date-time
contacts:
type: array
items:
type: string
format: iri-reference
example: 'https://example.com/'
Partner.jsonld: Partner.jsonld:
type: object type: object
description: '' description: ''
deprecated: false deprecated: false
required:
- name
- type
properties: properties:
'@context': '@context':
readOnly: true readOnly: true
@@ -1503,9 +1537,6 @@ components:
'@type': '@type':
readOnly: true readOnly: true
type: string type: string
id:
readOnly: true
type: integer
name: name:
type: string type: string
type: type:
@@ -1538,13 +1569,6 @@ components:
type: type:
- string - string
- 'null' - 'null'
createdAt:
type: string
format: date-time
contacts:
type: array
items:
$ref: '#/components/schemas/Contact.jsonld'
logo: logo:
'owl:maxCardinality': 1 'owl:maxCardinality': 1
type: type:
@@ -1552,6 +1576,21 @@ components:
- 'null' - 'null'
format: iri-reference format: iri-reference
example: 'https://example.com/' example: 'https://example.com/'
logoUrl:
type:
- string
- 'null'
createdAt:
type:
- string
- 'null'
format: date-time
contacts:
type: array
items:
type: string
format: iri-reference
example: 'https://example.com/'
Post: Post:
type: object type: object
description: '' description: ''


+ 3
- 0
src/ApiResource/ContactApi.php Zobrazit soubor

@@ -45,6 +45,7 @@ use Symfony\Component\Validator\Constraints\NotBlank;
processor: EntityClassDtoStateProcessor::class, processor: EntityClassDtoStateProcessor::class,
stateOptions: new Options(entityClass: Contact::class), stateOptions: new Options(entityClass: Contact::class),
)] )]

class ContactApi class ContactApi
{ {
#[ApiProperty(readable: false, writable: false, identifier: true)] #[ApiProperty(readable: false, writable: false, identifier: true)]
@@ -62,6 +63,8 @@ class ContactApi


public ?MediaObject $image = null; public ?MediaObject $image = null;


public ?string $imageUrl = null;

public ?string $position = null; public ?string $position = null;


public ?string $phone = null; public ?string $phone = null;


+ 2
- 0
src/ApiResource/PartnerApi.php Zobrazit soubor

@@ -77,6 +77,8 @@ class PartnerApi


public ?MediaObject $logo = null; public ?MediaObject $logo = null;


public ?string $logoUrl = null;

public ?\DateTimeImmutable $createdAt = null; public ?\DateTimeImmutable $createdAt = null;


/** /**


+ 1
- 0
src/Mapper/ContactEntityToApiMapper.php Zobrazit soubor

@@ -46,6 +46,7 @@ class ContactEntityToApiMapper implements MapperInterface
); );
$dto->birthday = $entity->getBirthday(); $dto->birthday = $entity->getBirthday();
$dto->image = $entity->getImage(); $dto->image = $entity->getImage();
$dto->imageUrl = $entity->getImage()?->getFilePath();
$dto->position = $entity->getPosition(); $dto->position = $entity->getPosition();
$dto->phone = $entity->getPhone(); $dto->phone = $entity->getPhone();
$dto->email = $entity->getEmail(); $dto->email = $entity->getEmail();


+ 3
- 3
src/Mapper/PartnerEntityToApiMapper.php Zobrazit soubor

@@ -14,9 +14,8 @@ use Symfonycasts\MicroMapper\MicroMapperInterface;
class PartnerEntityToApiMapper implements MapperInterface class PartnerEntityToApiMapper implements MapperInterface
{ {
public function __construct( public function __construct(
private MicroMapperInterface $microMapper,
)
{
private MicroMapperInterface $microMapper
) {
} }


public function load(object $from, string $toClass, array $context): object public function load(object $from, string $toClass, array $context): object
@@ -46,6 +45,7 @@ class PartnerEntityToApiMapper implements MapperInterface
$dto->country = $entity->getCountry(); $dto->country = $entity->getCountry();
$dto->website = $entity->getWebsite(); $dto->website = $entity->getWebsite();
$dto->logo = $entity->getLogo(); $dto->logo = $entity->getLogo();
$dto->logoUrl = $entity->getLogo()?->getFilePath();
$dto->createdAt = $entity->getCreatedAt(); $dto->createdAt = $entity->getCreatedAt();
$dto->contacts = array_map(function(Contact $contact) { $dto->contacts = array_map(function(Contact $contact) {
return $this->microMapper->map($contact, ContactApi::class, [ return $this->microMapper->map($contact, ContactApi::class, [


+ 0
- 1
src/Serializer/MediaObjectNormalizer.php Zobrazit soubor

@@ -15,7 +15,6 @@ use Symfony\Component\Serializer\SerializerAwareInterface;
use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Serializer\SerializerInterface;
use Vich\UploaderBundle\Storage\StorageInterface; use Vich\UploaderBundle\Storage\StorageInterface;


//final class MediaObjectNormalizer
#[AsDecorator('api_platform.jsonld.normalizer.item')] #[AsDecorator('api_platform.jsonld.normalizer.item')]
final class MediaObjectNormalizer implements NormalizerInterface, SerializerAwareInterface final class MediaObjectNormalizer implements NormalizerInterface, SerializerAwareInterface
{ {


Načítá se…
Zrušit
Uložit