ソースを参照

contact product post etc

master
Daniel 1年前
コミット
db5b1d61fb
13個のファイルの変更92行の追加8行の削除
  1. +1
    -1
      export/openapi.json
  2. +45
    -0
      export/openapi.yaml
  3. +1
    -0
      src/ApiResource/CommentApi.php
  4. +21
    -1
      src/ApiResource/ContactPartnerProductApi.php
  5. +4
    -2
      src/ApiResource/PartnerProductApi.php
  6. +1
    -0
      src/ApiResource/PostingApi.php
  7. +3
    -0
      src/ApiResource/TaskApi.php
  8. +1
    -0
      src/ApiResource/TaskNoteApi.php
  9. +3
    -3
      src/Mapper/ContactPartnerProductApiToEntityMapper.php
  10. +7
    -0
      src/Mapper/ContactPartnerProductEntityToApiMapper.php
  11. +1
    -1
      src/Mapper/PartnerFollowApiToEntityMapper.php
  12. +2
    -0
      src/Mapper/TaskEntityToApiMapper.php
  13. +2
    -0
      src/State/EntityToDtoStateProvider.php

+ 1
- 1
export/openapi.json
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 45
- 0
export/openapi.yaml ファイルの表示

@@ -365,6 +365,18 @@ paths:
style: form
explode: true
allowReserved: false
-
name: partnerProduct.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_contact_partner_products_post
@@ -4534,6 +4546,10 @@ components:
- 'null'
format: iri-reference
example: 'https://example.com/'
partnerProduct:
readOnly: true
description: '?PartnerProduct'
$ref: '#/components/schemas/PartnerProduct'
product:
readOnly: true
description: '?ProductApi'
@@ -4576,6 +4592,10 @@ components:
- 'null'
format: iri-reference
example: 'https://example.com/'
partnerProduct:
readOnly: true
description: '?PartnerProduct'
$ref: '#/components/schemas/PartnerProduct.jsonhal'
product:
readOnly: true
description: '?ProductApi'
@@ -4632,6 +4652,10 @@ components:
- 'null'
format: iri-reference
example: 'https://example.com/'
partnerProduct:
readOnly: true
description: '?PartnerProduct'
$ref: '#/components/schemas/PartnerProduct.jsonld'
product:
readOnly: true
description: '?ProductApi'
@@ -5418,6 +5442,7 @@ components:
format: iri-reference
example: 'https://example.com/'
product:
readOnly: true
description: '?ProductApi'
'owl:maxCardinality': 1
$ref: '#/components/schemas/Product'
@@ -5464,6 +5489,7 @@ components:
format: iri-reference
example: 'https://example.com/'
product:
readOnly: true
description: '?ProductApi'
'owl:maxCardinality': 1
$ref: '#/components/schemas/Product.jsonhal'
@@ -5524,6 +5550,7 @@ components:
format: iri-reference
example: 'https://example.com/'
product:
readOnly: true
description: '?ProductApi'
'owl:maxCardinality': 1
$ref: '#/components/schemas/Product.jsonld'
@@ -5613,6 +5640,7 @@ components:
format: iri-reference
example: 'https://example.com/'
numComments:
readOnly: true
type:
- integer
- 'null'
@@ -5761,6 +5789,7 @@ components:
format: iri-reference
example: 'https://example.com/'
numComments:
readOnly: true
type:
- integer
- 'null'
@@ -5916,6 +5945,7 @@ components:
format: iri-reference
example: 'https://example.com/'
numComments:
readOnly: true
type:
- integer
- 'null'
@@ -6505,6 +6535,11 @@ components:
type:
- boolean
- 'null'
numTaskNotes:
readOnly: true
type:
- integer
- 'null'
createdAt:
readOnly: true
type:
@@ -6609,6 +6644,11 @@ components:
type:
- boolean
- 'null'
numTaskNotes:
readOnly: true
type:
- integer
- 'null'
createdAt:
readOnly: true
type:
@@ -6727,6 +6767,11 @@ components:
type:
- boolean
- 'null'
numTaskNotes:
readOnly: true
type:
- integer
- 'null'
createdAt:
readOnly: true
type:


+ 1
- 0
src/ApiResource/CommentApi.php ファイルの表示

@@ -45,6 +45,7 @@ use Symfony\Component\Validator\Constraints\NotBlank;
// security: 'is_granted("ROLE_ADMIN")',
// )
],
order: ['createdAt' => 'DESC'],
security: 'is_granted("ROLE_USER")',
provider: EntityToDtoStateProvider::class,
processor: EntityClassDtoStateProcessor::class,


+ 21
- 1
src/ApiResource/ContactPartnerProductApi.php ファイルの表示

@@ -13,6 +13,7 @@ use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use App\Entity\ContactPartnerProduct;
use App\Entity\PartnerProduct;
use App\State\EntityClassDtoStateProcessor;
use App\State\EntityToDtoStateProvider;
use ApiPlatform\Metadata\Delete;
@@ -43,7 +44,10 @@ use Symfony\Component\Validator\Constraints\NotBlank;
processor: EntityClassDtoStateProcessor::class,
stateOptions: new Options(entityClass: ContactPartnerProduct::class),
)]
#[ApiFilter(SearchFilter::class, properties: ['contact' => 'exact'])]
#[ApiFilter(SearchFilter::class, properties: [
'contact' => 'exact',
'partnerProduct.product.name' => 'ipartial',
])]
class ContactPartnerProductApi
{
#[ApiProperty(readable: false, writable: false, identifier: true)]
@@ -55,6 +59,22 @@ class ContactPartnerProductApi
#[NotBlank]
public ?PartnerProductApi $partnerProductIri = null;

/**
* @var $product ?PartnerProduct
*/
#[ApiProperty(
writable: false,
readableLink: true,
writableLink: false,
builtinTypes: [
new Type(
'object',
class: PartnerProductApi::class,
)
]
)]
public ?PartnerProductApi $partnerProduct = null;

/**
* @var $product ?ProductApi
*/


+ 4
- 2
src/ApiResource/PartnerProductApi.php ファイルの表示

@@ -71,15 +71,16 @@ class PartnerProductApi
public ?PartnerApi $partner = null;

#[NotBlank]
#[ApiProperty(writable: true)]
public ?PartnerApi $partnerIri = null;

/**
* @var $product ?ProductApi
*/
#[ApiProperty(
writable: true,
writable: false,
readableLink: true,
writableLink: true,
writableLink: false,
builtinTypes: [
new Type(
'object',
@@ -90,6 +91,7 @@ class PartnerProductApi
public ?ProductApi $product = null;

#[NotBlank]
#[ApiProperty(writable: true)]
public ?ProductApi $productIri = null;

#[ApiProperty(writable: false)]


+ 1
- 0
src/ApiResource/PostingApi.php ファイルの表示

@@ -173,6 +173,7 @@ class PostingApi implements OwnerInterface
#[Groups(['posting:create'])]
public ?SaleApi $saleIri = null;

#[ApiProperty(writable: false)]
public ?int $numComments = null;

#[ApiProperty(writable: false)]


+ 3
- 0
src/ApiResource/TaskApi.php ファイルの表示

@@ -167,6 +167,9 @@ class TaskApi
#[Assert\NotNull]
public ?bool $completed = null;

#[ApiProperty(writable: false)]
public ?int $numTaskNotes = null;

#[ApiProperty(writable: false)]
public ?\DateTimeImmutable $createdAt = null;



+ 1
- 0
src/ApiResource/TaskNoteApi.php ファイルの表示

@@ -41,6 +41,7 @@ use Symfony\Component\Validator\Constraints\NotBlank;
// security: 'is_granted("ROLE_ADMIN")',
// )
],
order: ['createdAt' => 'DESC'],
security: 'is_granted("ROLE_USER")',
provider: EntityToDtoStateProvider::class,
processor: EntityClassDtoStateProcessor::class,


+ 3
- 3
src/Mapper/ContactPartnerProductApiToEntityMapper.php ファイルの表示

@@ -53,7 +53,7 @@ class ContactPartnerProductApiToEntityMapper implements MapperInterface

assert($contact instanceof Contact);
assert($partnerProduct instanceof PartnerProduct);
$entity = new PartnerProduct($contact, $partnerProduct);
$entity = new ContactPartnerProduct($contact, $partnerProduct);
}

if (!$entity) {
@@ -66,9 +66,9 @@ class ContactPartnerProductApiToEntityMapper implements MapperInterface
public function populate(object $from, object $to, array $context): object
{
$dto = $from;
assert($dto instanceof PartnerProductApi);
assert($dto instanceof ContactPartnerProductApi);
$entity = $to;
assert($entity instanceof PartnerProduct);
assert($entity instanceof ContactPartnerProduct);
return $entity;
}
}

+ 7
- 0
src/Mapper/ContactPartnerProductEntityToApiMapper.php ファイルの表示

@@ -47,6 +47,13 @@ class ContactPartnerProductEntityToApiMapper implements MapperInterface
MicroMapperInterface::MAX_DEPTH => 1,
]);

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

$dto->product = null;
if ($entity->getPartnerProduct() !== null && $entity->getPartnerProduct()->getProduct() !== null) {
$dto->product = $this->microMapper->map($entity->getPartnerProduct()->getProduct(), ProductApi::class, [


+ 1
- 1
src/Mapper/PartnerFollowApiToEntityMapper.php ファイルの表示

@@ -34,7 +34,7 @@ class PartnerFollowApiToEntityMapper implements MapperInterface
} else {
$user = $this->security->getUser();
assert($user instanceof User);
if ($dto->partner === null) {
if ($dto->partnerIri === null) {
throw new \Exception('Partner missing');
}
$partner = $this->microMapper->map($dto->partnerIri, Partner::class, [


+ 2
- 0
src/Mapper/TaskEntityToApiMapper.php ファイルの表示

@@ -83,6 +83,8 @@ class TaskEntityToApiMapper implements MapperInterface
MicroMapperInterface::MAX_DEPTH => 1,
]);

$dto->numTaskNotes = count($entity->getTaskNotes());

$dto->prio = $entity->getPrio();
$dto->completed = $entity->getCompleted();
$dto->createdAt = $entity->getCreatedAt();


+ 2
- 0
src/State/EntityToDtoStateProvider.php ファイルの表示

@@ -28,12 +28,14 @@ class EntityToDtoStateProvider implements ProviderInterface
$resourceClass = $operation->getClass();
if ($operation instanceof CollectionOperationInterface) {
$entities = $this->collectionProvider->provide($operation, $uriVariables, $context);

assert($entities instanceof Paginator);

$dtos = [];
foreach ($entities as $entity) {
$dtos[] = $this->mapEntityToDto($entity, $resourceClass);
}
return $dtos;

return new TraversablePaginator(
new \ArrayIterator($dtos),


読み込み中…
キャンセル
保存