Daniel 1 год назад
Родитель
Сommit
d0db3260c1
43 измененных файлов: 874 добавлений и 1255 удалений
  1. +1
    -1
      export/openapi.json
  2. +397
    -949
      export/openapi.yaml
  3. +16
    -5
      src/ApiResource/CommentApi.php
  4. +34
    -5
      src/ApiResource/ContactApi.php
  5. +18
    -4
      src/ApiResource/ContactPartnerProductApi.php
  6. +45
    -8
      src/ApiResource/DocumentApi.php
  7. +2
    -22
      src/ApiResource/PartnerApi.php
  8. +6
    -14
      src/ApiResource/PartnerFollowApi.php
  9. +7
    -9
      src/ApiResource/PartnerProductApi.php
  10. +70
    -28
      src/ApiResource/PostingApi.php
  11. +15
    -4
      src/ApiResource/ProductApi.php
  12. +47
    -21
      src/ApiResource/SaleApi.php
  13. +14
    -2
      src/ApiResource/SaleSummary.php
  14. +73
    -33
      src/ApiResource/TaskApi.php
  15. +17
    -5
      src/ApiResource/TaskNoteApi.php
  16. +3
    -0
      src/ApiResource/UserApi.php
  17. +18
    -9
      src/ApiResource/UserProductApi.php
  18. +2
    -2
      src/Mapper/CommentApiToEntityMapper.php
  19. +1
    -2
      src/Mapper/CommentEntityToApiMapper.php
  20. +1
    -1
      src/Mapper/ContactApiToEntityMapper.php
  21. +2
    -2
      src/Mapper/ContactEntityToApiMapper.php
  22. +4
    -4
      src/Mapper/ContactPartnerProductApiToEntityMapper.php
  23. +11
    -3
      src/Mapper/ContactPartnerProductEntityToApiMapper.php
  24. +2
    -2
      src/Mapper/DocumentApiToEntityMapper.php
  25. +2
    -5
      src/Mapper/DocumentEntityToApiMapper.php
  26. +1
    -19
      src/Mapper/PartnerEntityToApiMapper.php
  27. +1
    -1
      src/Mapper/PartnerFollowApiToEntityMapper.php
  28. +4
    -5
      src/Mapper/PartnerFollowEntityToApiMapper.php
  29. +4
    -9
      src/Mapper/PartnerProductApiToEntityMapper.php
  30. +2
    -4
      src/Mapper/PartnerProductEntityToApiMapper.php
  31. +8
    -8
      src/Mapper/PostingApiToEntityMapper.php
  32. +6
    -20
      src/Mapper/PostingEntityToApiMapper.php
  33. +0
    -1
      src/Mapper/ProductEntityToApiMapper.php
  34. +4
    -4
      src/Mapper/SaleApiToEntityMapper.php
  35. +6
    -13
      src/Mapper/SaleEntityToApiMapper.php
  36. +9
    -9
      src/Mapper/TaskApiToEntityMapper.php
  37. +12
    -13
      src/Mapper/TaskEntityToApiMapper.php
  38. +2
    -2
      src/Mapper/TaskNoteApiToEntityMapper.php
  39. +1
    -2
      src/Mapper/TaskNoteEntityToApiMapper.php
  40. +1
    -0
      src/Mapper/UserEntityToApiMapper.php
  41. +2
    -2
      src/Mapper/UserProductApiToEntityMapper.php
  42. +3
    -2
      src/Mapper/UserProductEntityToApiMapper.php
  43. +0
    -1
      src/State/SaleSummaryStateProvider.php

+ 1
- 1
export/openapi.json
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


+ 397
- 949
export/openapi.yaml
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


+ 16
- 5
src/ApiResource/CommentApi.php Просмотреть файл

@@ -22,6 +22,7 @@ use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post;
use App\Validator\IsValidOwner;
use Symfony\Component\PropertyInfo\Type;
use Symfony\Component\Serializer\Attribute\Groups;
use Symfony\Component\Validator\Constraints\NotBlank;

@@ -58,13 +59,23 @@ class CommentApi implements OwnerInterface
#[NotBlank]
public ?string $message = null;

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

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

public ?PostingApi $post = null;
public ?PostingApi $postIri = null;

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


+ 34
- 5
src/ApiResource/ContactApi.php Просмотреть файл

@@ -21,6 +21,7 @@ use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post;
use Symfony\Component\PropertyInfo\Type;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\NotBlank;

@@ -61,9 +62,27 @@ class ContactApi
#[NotBlank]
public ?string $lastName = null;

#[NotBlank]
public ?string $fullName = null;

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

#[NotBlank]
public ?PartnerApi $partnerIri = null;

public ?\DateTimeImmutable $birthday = null;

public ?MediaObject $image = null;
@@ -84,12 +103,22 @@ class ContactApi
#[ApiProperty(writable: false)]
public array $posts = [];

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

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

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

+ 18
- 4
src/ApiResource/ContactPartnerProductApi.php Просмотреть файл

@@ -19,6 +19,7 @@ use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Post;
use Symfony\Component\PropertyInfo\Type;
use Symfony\Component\Validator\Constraints\NotBlank;

#[ApiResource(
@@ -49,13 +50,26 @@ class ContactPartnerProductApi
public ?int $id = null;

#[NotBlank]
public ?ContactApi $contact = null;
public ?ContactApi $contactIri = null;

#[NotBlank]
public ?PartnerProductApi $partnerProduct = null;
public ?PartnerProductApi $partnerProductIri = null;

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

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

+ 45
- 8
src/ApiResource/DocumentApi.php Просмотреть файл

@@ -25,6 +25,7 @@ use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post;
use App\Validator\IsValidOwner;
use Symfony\Component\PropertyInfo\Type;
use Symfony\Component\Serializer\Attribute\Groups;
use Symfony\Component\Validator\Constraints\NotBlank;

@@ -63,15 +64,41 @@ class DocumentApi

public ?string $description = null;

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

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

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

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

#[NotBlank]
public ?DocumentObject $documentObject = null;
@@ -79,12 +106,22 @@ class DocumentApi
#[ApiProperty(writable: false)]
public ?string $documentUrl = null;

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

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

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

+ 2
- 22
src/ApiResource/PartnerApi.php Просмотреть файл

@@ -24,6 +24,7 @@ use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post;
use Symfony\Component\PropertyInfo\Type;
use Symfony\Component\Validator\Constraints\NotBlank;

#[ApiResource(
@@ -82,29 +83,8 @@ class PartnerApi
public ?string $logoUrl = null;

#[ApiProperty(writable: false)]
public ?UserApi $createdBy = null;

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

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

/**
* @var $posts array<int, PostingApi>
*/
#[ApiProperty(writable: false)]
public array $posts = [];

/**
* @var array<int, ContactApi>
*/
#[ApiProperty(writable: false)]
public array $contacts = [];

/**
* @var array<int, ContactApi>
*/
#[ApiProperty(writable: false)]
public array $partnerProducts = [];
}

+ 6
- 14
src/ApiResource/PartnerFollowApi.php Просмотреть файл

@@ -12,9 +12,7 @@ use ApiPlatform\Doctrine\Orm\State\Options;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use App\Entity\Partner;
use App\Entity\PartnerFollow;
use App\Entity\User;
use App\Interface\OwnerInterface;
use App\State\EntityClassDtoStateProcessor;
use App\State\EntityToDtoStateProvider;
@@ -23,7 +21,6 @@ use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Post;
use Symfony\Component\PropertyInfo\Type;
use Symfony\Component\Serializer\Attribute\Groups;
use Symfony\Component\Validator\Constraints\NotBlank;

#[ApiResource(
@@ -57,20 +54,15 @@ class PartnerFollowApi implements OwnerInterface
#[ApiProperty(readable: false, writable: false, identifier: true)]
public ?int $id = null;

#[ApiProperty(writable: false)]
public ?UserApi $user = null;

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

#[NotBlank]
/**
* @var $partner ?PartnerApi
*/
#[ApiProperty(
writable: true,
writable: false,
readableLink: true,
writableLink: true,
writableLink: false,
builtinTypes: [
new Type(
'object',
@@ -80,14 +72,14 @@ class PartnerFollowApi implements OwnerInterface
)]
public ?PartnerApi $partner = null;

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

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

public function getOwner(): ?UserApi
{
return $this->user;
return $this->userIri;
}
}

+ 7
- 9
src/ApiResource/PartnerProductApi.php Просмотреть файл

@@ -54,14 +54,13 @@ class PartnerProductApi
#[ApiProperty(readable: false, writable: false, identifier: true)]
public ?int $id = null;

#[NotBlank]
/**
* @var $product ?PartnerApi
* @var $partner ?PartnerApi
*/
#[ApiProperty(
writable: true,
writable: false,
readableLink: true,
writableLink: true,
writableLink: false,
builtinTypes: [
new Type(
'object',
@@ -71,10 +70,9 @@ class PartnerProductApi
)]
public ?PartnerApi $partner = null;

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

#[NotBlank]
public ?PartnerApi $partnerIri = null;

/**
* @var $product ?ProductApi
*/
@@ -91,8 +89,8 @@ class PartnerProductApi
)]
public ?ProductApi $product = null;

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

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

+ 70
- 28
src/ApiResource/PostingApi.php Просмотреть файл

@@ -78,59 +78,101 @@ class PostingApi implements OwnerInterface
#[Groups(['posting:create', 'posting:patch'])]
public ?string $message = null;

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

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

#[ApiProperty(writable: true)]
#[Groups(['posting:create'])]
#[Assert\NotBlank(groups: ['posting:create'])]
/**
* @var $partner ?PartnerApi
*/
#[ApiProperty(
writable: false,
readableLink: true,
writableLink: false,
builtinTypes: [
new Type(
'object',
class: PartnerApi::class,
)
]
)]
public ?PartnerApi $partner = null;

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

#[ApiProperty(writable: false)]
public ?PartnerType $partnerType = null;

#[ApiProperty(writable: true)]
#[Groups(['posting:create'])]
#[Assert\NotBlank(groups: ['posting:create'])]
public ?ProductApi $product = null;
public ?PartnerApi $partnerIri = null;

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

#[ApiProperty(writable: true)]
#[Groups(['posting:create'])]
public ?ContactApi $contact = null;
#[Assert\NotBlank(groups: ['posting:create'])]
public ?ProductApi $productIri = null;

#[ApiProperty(writable: false)]
public ?string $contactName = null;
/**
* @var $contact ?ContactApi
*/
#[ApiProperty(
writable: false,
readableLink: true,
writableLink: false,
builtinTypes: [
new Type(
'object',
class: ContactApi::class,
)
]
)]
public ?ContactApi $contact = null;

#[ApiProperty(writable: true)]
#[Groups(['posting:create'])]
public ?SaleApi $sale = null;
public ?ContactApi $contactIri = null;

/**
* @var $comments array<int, CommentApi>
* @var $sale ?SaleApi
*/
#[ApiProperty(
writable: false,
readableLink: true,
writableLink: true,
writableLink: false,
builtinTypes: [
new Type(
'object',
collection: true,
collectionKeyType: [new Type('int')],
collectionValueType: new Type('object', class: CommentApi::class)
class: ContactApi::class,
)
]
)]
public array $comments = [];
public ?SaleApi $sale = null;

#[Groups(['posting:create'])]
public ?SaleApi $saleIri = null;


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


+ 15
- 4
src/ApiResource/ProductApi.php Просмотреть файл

@@ -23,6 +23,7 @@ use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post;
use Symfony\Component\PropertyInfo\Type;
use Symfony\Component\Validator\Constraints\NotBlank;

#[ApiResource(
@@ -66,12 +67,22 @@ class ProductApi
#[ApiProperty(writable: false)]
public ?string $imageUrl = null;

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

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

public ?\DateTimeImmutable $createdAt = null;

}

+ 47
- 21
src/ApiResource/SaleApi.php Просмотреть файл

@@ -22,6 +22,7 @@ use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post;
use Symfony\Component\PropertyInfo\Type;
use Symfony\Component\Validator\Constraints\NotBlank;

#[ApiResource(
@@ -53,28 +54,59 @@ class SaleApi implements OwnerInterface
#[ApiProperty(readable: false, writable: false, identifier: true)]
public ?int $id = null;

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

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

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

#[ApiProperty(writable: false)]
public PartnerType $partnerType;

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

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

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

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

#[NotBlank]
public ?int $turnover = null;
@@ -90,12 +122,6 @@ class SaleApi implements OwnerInterface
#[ApiProperty(writable: false)]
public ?\DateTimeImmutable $createdAt = null;

/**
* @var $posts array<int, PostingApi>
*/
#[ApiProperty(writable: false)]
public array $posts = [];

public function getOwner(): ?UserApi
{
return $this->owner;


+ 14
- 2
src/ApiResource/SaleSummary.php Просмотреть файл

@@ -49,10 +49,22 @@ class SaleSummary
$this->userId = $userId;
}

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

public ?string $ownerName = null;

public ?int $turnover = null;

public ?int $profit = null;


+ 73
- 33
src/ApiResource/TaskApi.php Просмотреть файл

@@ -68,64 +68,104 @@ class TaskApi
#[Assert\NotBlank]
public ?string $description = null;

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

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

#[Assert\NotBlank]
/**
* @var $assignedTo ?UserApi
*/
#[ApiProperty(
writable: false,
readableLink: true,
writableLink: false,
builtinTypes: [
new Type(
'object',
class: UserApi::class,
)
]
)]
public ?UserApi $assignedTo = null;

#[ApiProperty(writable: false)]
public ?string $assignedToName = null;
#[Assert\NotBlank]
public ?UserApi $assignedToIri = null;

#[Assert\NotBlank]
public ?\DateTimeImmutable $dueAt = null;

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

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

#[ApiProperty(writable: false)]
public ?PartnerType $partnerType = null;
public ?PartnerApi $partnerIri = null;

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

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

public ?ContactApi $contact = null;

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

#[Assert\NotBlank]
public PrioType $prio;

#[Assert\NotNull]
public ?bool $completed = null;
#[NotBlank]
public ?ProductApi $productIri = null;

/**
* @var $taskNotes array<int, TaskNoteApi>
* @var $contact ?ContactApi
*/
#[ApiProperty(
writable: false,
readableLink: true,
writableLink: true,
writableLink: false,
builtinTypes: [
new Type(
'object',
collection: true,
collectionKeyType: [new Type('int')],
collectionValueType: new Type('object', class: TaskNoteApi::class)
class: ContactApi::class,
)
]
)]
public array $taskNotes = [];
public ?ContactApi $contact = null;

public ?ContactApi $contactIri = null;

#[Assert\NotBlank]
public PrioType $prio;

#[Assert\NotNull]
public ?bool $completed = null;

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


+ 17
- 5
src/ApiResource/TaskNoteApi.php Просмотреть файл

@@ -21,6 +21,7 @@ use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post;
use Symfony\Component\PropertyInfo\Type;
use Symfony\Component\Validator\Constraints\NotBlank;

#[ApiResource(
@@ -54,13 +55,24 @@ class TaskNoteApi implements OwnerInterface
#[NotBlank]
public ?string $message = null;

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

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

public ?TaskApi $task = null;
#[NotBlank]
public ?TaskApi $taskIri = null;

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


+ 3
- 0
src/ApiResource/UserApi.php Просмотреть файл

@@ -67,6 +67,9 @@ class UserApi
#[ApiProperty(writable: false)]
public ?string $imageUrl = null;

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

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


+ 18
- 9
src/ApiResource/UserProductApi.php Просмотреть файл

@@ -52,20 +52,29 @@ class UserProductApi implements OwnerInterface
#[ApiProperty(readable: false, writable: false, identifier: true)]
public ?int $id = null;

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

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

#[NotBlank]
/**
* @var $product ?ProductApi
*/
#[ApiProperty(
writable: true,
writable: false,
readableLink: true,
writableLink: true,
writableLink: false,
builtinTypes: [
new Type(
'object',
@@ -75,8 +84,8 @@ class UserProductApi implements OwnerInterface
)]
public ?ProductApi $product = null;

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

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


+ 2
- 2
src/Mapper/CommentApiToEntityMapper.php Просмотреть файл

@@ -34,10 +34,10 @@ class CommentApiToEntityMapper implements MapperInterface
} else {
$user = $this->security->getUser();
assert($user instanceof User);
if ($dto->post === null) {
if ($dto->postIri === null) {
throw new \Exception('Posting missing');
}
$posting = $this->microMapper->map($dto->post, Posting::class, [
$posting = $this->microMapper->map($dto->postIri, Posting::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
assert($posting instanceof Posting);


+ 1
- 2
src/Mapper/CommentEntityToApiMapper.php Просмотреть файл

@@ -41,9 +41,8 @@ class CommentEntityToApiMapper implements MapperInterface
$dto->owner = $this->microMapper->map($entity->getOwner(), UserApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->ownerName = $entity->getOwner()?->getFirstName()." ".$entity->getOwner()?->getLastName();

$dto->post = $this->microMapper->map($entity->getPosting(), PostingApi::class, [
$dto->postIri = $this->microMapper->map($entity->getPosting(), PostingApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);



+ 1
- 1
src/Mapper/ContactApiToEntityMapper.php Просмотреть файл

@@ -38,7 +38,7 @@ class ContactApiToEntityMapper implements MapperInterface
if ($dto->partner === null) {
throw new \Exception('Partner missing');
}
$partner = $this->microMapper->map($dto->partner, Partner::class, [
$partner = $this->microMapper->map($dto->partnerIri, Partner::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$entity = new Contact($partner, $user);


+ 2
- 2
src/Mapper/ContactEntityToApiMapper.php Просмотреть файл

@@ -43,7 +43,8 @@ class ContactEntityToApiMapper implements MapperInterface

$dto->firstName = $entity->getFirstName();
$dto->lastName = $entity->getLastName();
$dto->partner = $this->microMapper->map(
$dto->fullName = $entity->getFirstName() . " " . $entity->getLastName();
$dto->partnerIri = $dto->partner = $this->microMapper->map(
$entity->getPartner(), PartnerApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]
@@ -57,7 +58,6 @@ class ContactEntityToApiMapper implements MapperInterface
$dto->createdBy = $this->microMapper->map($entity->getCreatedBy(), UserApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->createdByName = $entity->getCreatedBy()?->getFirstName() . ' ' . $entity->getCreatedBy()?->getLastName();
$dto->createdAt = $entity->getCreatedAt();

$dto->posts = array_map(function(Posting $posting) {


+ 4
- 4
src/Mapper/ContactPartnerProductApiToEntityMapper.php Просмотреть файл

@@ -33,17 +33,17 @@ class ContactPartnerProductApiToEntityMapper implements MapperInterface
if ($dto->id) {
$entity = $this->repository->find($dto->id);
} else {
if ($dto->contact === null) {
if ($dto->contactIri === null) {
throw new \Exception('Contact missing');
}
$contact = $this->microMapper->map($dto->contact, Contact::class, [
$contact = $this->microMapper->map($dto->contactIri, Contact::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);

if ($dto->partnerProduct === null) {
if ($dto->partnerProductIri === null) {
throw new \Exception('PartnerProduct missing');
}
$partnerProduct = $this->microMapper->map($dto->partnerProduct, PartnerProduct::class, [
$partnerProduct = $this->microMapper->map($dto->partnerProductIri, PartnerProduct::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);



+ 11
- 3
src/Mapper/ContactPartnerProductEntityToApiMapper.php Просмотреть файл

@@ -5,7 +5,9 @@ namespace App\Mapper;
use App\ApiResource\ContactApi;
use App\ApiResource\ContactPartnerProductApi;
use App\ApiResource\PartnerProductApi;
use App\ApiResource\ProductApi;
use App\Entity\ContactPartnerProduct;
use App\Entity\Product;
use Symfonycasts\MicroMapper\AsMapper;
use Symfonycasts\MicroMapper\MapperInterface;
use Symfonycasts\MicroMapper\MicroMapperInterface;
@@ -37,14 +39,20 @@ class ContactPartnerProductEntityToApiMapper implements MapperInterface
assert($entity instanceof ContactPartnerProduct);
assert($dto instanceof ContactPartnerProductApi);

$dto->contact = $this->microMapper->map($entity->getContact(), ContactApi::class, [
$dto->contactIri = $this->microMapper->map($entity->getContact(), ContactApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);

$dto->partnerProduct = $this->microMapper->map($entity->getPartnerProduct(), PartnerProductApi::class, [
$dto->partnerProductIri = $this->microMapper->map($entity->getPartnerProduct(), PartnerProductApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->productName = $entity->getPartnerProduct()?->getProduct()?->getName();

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

$dto->createdAt = $entity->getCreatedAt();



+ 2
- 2
src/Mapper/DocumentApiToEntityMapper.php Просмотреть файл

@@ -59,14 +59,14 @@ class DocumentApiToEntityMapper implements MapperInterface
$entity->setDescription($dto->description);
if ($dto->partner !== null) {
$entity->setPartner(
$this->microMapper->map($dto->partner, Partner::class, [
$this->microMapper->map($dto->partnerIri, Partner::class, [
MicroMapperInterface::MAX_DEPTH => 1,
])
);
}
if ($dto->product !== null) {
$entity->setProduct(
$this->microMapper->map($dto->product, Product::class, [
$this->microMapper->map($dto->productIri, Product::class, [
MicroMapperInterface::MAX_DEPTH => 1,
])
);


+ 2
- 5
src/Mapper/DocumentEntityToApiMapper.php Просмотреть файл

@@ -47,17 +47,15 @@ class DocumentEntityToApiMapper implements MapperInterface
$dto->description = $entity->getDescription();

if ($entity->getPartner()) {
$dto->partner = $this->microMapper->map($entity->getPartner(), PartnerApi::class, [
$dto->partnerIri = $dto->partner = $this->microMapper->map($entity->getPartner(), PartnerApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->partnerName = $entity->getPartner()->getName();
}

if ($entity->getProduct()) {
$dto->product = $this->microMapper->map($entity->getProduct(), ProductApi::class, [
$dto->productIri = $dto->product = $this->microMapper->map($entity->getProduct(), ProductApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->productName = $entity->getProduct()->getName();
}

$dto->documentObject = $entity->getDocumentObject();
@@ -66,7 +64,6 @@ class DocumentEntityToApiMapper implements MapperInterface
$dto->createdBy = $this->microMapper->map($entity->getCreatedBy(), UserApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->createdByName = $entity->getCreatedBy()?->getFirstName() . ' ' . $entity->getCreatedBy()?->getLastName();
$dto->createdAt = $entity->getCreatedAt();

return $dto;


+ 1
- 19
src/Mapper/PartnerEntityToApiMapper.php Просмотреть файл

@@ -55,28 +55,10 @@ class PartnerEntityToApiMapper implements MapperInterface
$dto->website = $entity->getWebsite();
$dto->logo = $entity->getLogo();
$dto->logoUrl = $this->fileUrlService->getFileUrl($entity->getLogo());
$dto->createdBy = $this->microMapper->map($entity->getCreatedBy(), UserApi::class, [
$dto->createdByIri = $this->microMapper->map($entity->getCreatedBy(), UserApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->createdByName = $entity->getCreatedBy()?->getFirstName() . ' ' . $entity->getCreatedBy()?->getLastName();
$dto->createdAt = $entity->getCreatedAt();
$dto->posts = array_map(function(Posting $posting) {
return $this->microMapper->map($posting, PostingApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
}, $entity->getPostings()->getValues());

$dto->contacts = array_map(function(Contact $contact) {
return $this->microMapper->map($contact, ContactApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
}, $entity->getContacts()->getValues());

$dto->partnerProducts = array_map(function(PartnerProduct $contact) {
return $this->microMapper->map($contact, PartnerProductApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
}, $entity->getPartnerProducts()->getValues());

return $dto;
}


+ 1
- 1
src/Mapper/PartnerFollowApiToEntityMapper.php Просмотреть файл

@@ -37,7 +37,7 @@ class PartnerFollowApiToEntityMapper implements MapperInterface
if ($dto->partner === null) {
throw new \Exception('Partner missing');
}
$partner = $this->microMapper->map($dto->partner, Partner::class, [
$partner = $this->microMapper->map($dto->partnerIri, Partner::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
assert($partner instanceof Partner);


+ 4
- 5
src/Mapper/PartnerFollowEntityToApiMapper.php Просмотреть файл

@@ -37,15 +37,14 @@ class PartnerFollowEntityToApiMapper implements MapperInterface
assert($entity instanceof PartnerFollow);
assert($dto instanceof PartnerFollowApi);

$dto->user = $this->microMapper->map($entity->getUser(), UserApi::class, [
$dto->userIri = $this->microMapper->map($entity->getUser(), UserApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->userName = $entity->getUser()?->getFirstName()." ".$entity->getUser()?->getLastName();

$dto->partner = $this->microMapper->map($entity->getPartner(), PartnerApi::class, [
$dto->partnerIri = $dto->partner = $this->microMapper->map($entity->getPartner(), PartnerApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->partnerName = $entity->getPartner()?->getName();



$dto->createdAt = $entity->getCreatedAt();



+ 4
- 9
src/Mapper/PartnerProductApiToEntityMapper.php Просмотреть файл

@@ -2,16 +2,11 @@

namespace App\Mapper;

use App\ApiResource\PartnerFollowApi;
use App\ApiResource\PartnerProductApi;
use App\Entity\Partner;
use App\Entity\PartnerFollow;
use App\Entity\PartnerProduct;
use App\Entity\Product;
use App\Entity\User;
use App\Repository\PartnerFollowRepository;
use App\Repository\PartnerProductRepository;
use Symfony\Bundle\SecurityBundle\Security;
use Symfonycasts\MicroMapper\AsMapper;
use Symfonycasts\MicroMapper\MapperInterface;
use Symfonycasts\MicroMapper\MicroMapperInterface;
@@ -35,17 +30,17 @@ class PartnerProductApiToEntityMapper implements MapperInterface
if ($dto->id) {
$entity = $this->repository->find($dto->id);
} else {
if ($dto->partner === null) {
if ($dto->partnerIri === null) {
throw new \Exception('Partner missing');
}
$partner = $this->microMapper->map($dto->partner, Partner::class, [
$partner = $this->microMapper->map($dto->partnerIri, Partner::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);

if ($dto->product === null) {
if ($dto->productIri === null) {
throw new \Exception('Product missing');
}
$product = $this->microMapper->map($dto->product, Product::class, [
$product = $this->microMapper->map($dto->productIri, Product::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
assert($partner instanceof Partner);


+ 2
- 4
src/Mapper/PartnerProductEntityToApiMapper.php Просмотреть файл

@@ -37,15 +37,13 @@ class PartnerProductEntityToApiMapper implements MapperInterface
assert($entity instanceof PartnerProduct);
assert($dto instanceof PartnerProductApi);

$dto->partner = $this->microMapper->map($entity->getPartner(), PartnerApi::class, [
$dto->partnerIri = $this->microMapper->map($entity->getPartner(), PartnerApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->partnerName = $entity->getPartner()?->getName();

$dto->product = $this->microMapper->map($entity->getProduct(), ProductApi::class, [
$dto->productIri = $dto->partner = $dto->product = $this->microMapper->map($entity->getProduct(), ProductApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->productName = $entity->getProduct()?->getName();

$dto->createdAt = $entity->getCreatedAt();



+ 8
- 8
src/Mapper/PostingApiToEntityMapper.php Просмотреть файл

@@ -42,26 +42,26 @@ class PostingApiToEntityMapper implements MapperInterface
if ($dto->partner === null) {
throw new \Exception('Partner missing');
}
$partner = $this->microMapper->map($dto->partner, Partner::class, [
$partner = $this->microMapper->map($dto->partnerIri, Partner::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
if ($dto->product === null) {
throw new \Exception('Product missing');
}
$product = $this->microMapper->map($dto->product, Product::class, [
$product = $this->microMapper->map($dto->productIri, Product::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$contact = null;
if ($dto->contact) {
assert($dto->contact instanceof ContactApi);
$contact = $this->microMapper->map($dto->contact, Contact::class, [
if ($dto->contactIri) {
assert($dto->contactIri instanceof ContactApi);
$contact = $this->microMapper->map($dto->contactIri, Contact::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
}
$sale = null;
if ($dto->sale) {
assert($dto->sale instanceof SaleApi);
$sale = $this->microMapper->map($dto->sale, Sale::class, [
if ($dto->saleIri) {
assert($dto->saleIri instanceof SaleApi);
$sale = $this->microMapper->map($dto->saleIri, Sale::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
}


+ 6
- 20
src/Mapper/PostingEntityToApiMapper.php Просмотреть файл

@@ -2,14 +2,12 @@

namespace App\Mapper;

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;
use App\Entity\Posting;
use Symfonycasts\MicroMapper\AsMapper;
use Symfonycasts\MicroMapper\MapperInterface;
@@ -47,41 +45,29 @@ class PostingEntityToApiMapper implements MapperInterface
$dto->owner = $this->microMapper->map($entity->getOwner(), UserApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->ownerName = $entity->getOwner()?->getFirstName()." ".$entity->getOwner()?->getLastName();

$dto->partner = $this->microMapper->map($entity->getPartner(), PartnerApi::class, [
$dto->partnerIri = $dto->partner = $this->microMapper->map($entity->getPartner(), PartnerApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->partnerName = $entity->getPartner()?->getName();
$dto->partnerType = $entity->getPartner()?->getType();

$dto->product = $this->microMapper->map($entity->getProduct(), ProductApi::class, [
$dto->productIri = $dto->product = $this->microMapper->map($entity->getProduct(), ProductApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->productName = $entity->getProduct()?->getName();

$dto->contact = null;
$dto->contactName = null;
$dto->contactIri = $dto->contact = null;
if ($entity->getContact() !== null) {
$dto->contact = $this->microMapper->map($entity->getContact(), ContactApi::class, [
$dto->contactIri = $dto->contact = $this->microMapper->map($entity->getContact(), ContactApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->contactName = $entity->getContact()->getFirstName() . ' ' . $entity->getContact()->getLastName();
}

$dto->sale = null;
$dto->saleIri = $dto->sale = null;
if ($entity->getSale() !== null) {
$dto->sale = $this->microMapper->map($entity->getSale(), SaleApi::class, [
$dto->saleIri = $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,
]);
}, $entity->getComments()->getValues());

$dto->createdAt = $entity->getCreatedAt();

return $dto;


+ 0
- 1
src/Mapper/ProductEntityToApiMapper.php Просмотреть файл

@@ -44,7 +44,6 @@ class ProductEntityToApiMapper implements MapperInterface
$dto->createdBy = $this->microMapper->map($entity->getCreatedBy(), UserApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->createdByName = $entity->getCreatedBy()?->getFirstName() . ' ' . $entity->getCreatedBy()?->getLastName();
return $dto;
}
}

+ 4
- 4
src/Mapper/SaleApiToEntityMapper.php Просмотреть файл

@@ -37,16 +37,16 @@ class SaleApiToEntityMapper 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->partner, Partner::class, [
$partner = $this->microMapper->map($dto->partnerIri, Partner::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
if ($dto->product === null) {
if ($dto->productIri === null) {
throw new \Exception('Product missing');
}
$product = $this->microMapper->map($dto->product, Product::class, [
$product = $this->microMapper->map($dto->productIri, Product::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
assert($partner instanceof Partner);


+ 6
- 13
src/Mapper/SaleEntityToApiMapper.php Просмотреть файл

@@ -2,16 +2,13 @@

namespace App\Mapper;

use App\ApiResource\CommentApi;
use App\ApiResource\PartnerApi;
use App\ApiResource\ProductApi;
use App\ApiResource\SaleApi;
use App\ApiResource\UserApi;
use App\ApiResource\PostingApi;
use App\Entity\Comment;
use App\Entity\Posting;
use App\Entity\Sale;
use Symfony\Bundle\SecurityBundle\Security;
use Symfonycasts\MicroMapper\AsMapper;
use Symfonycasts\MicroMapper\MapperInterface;
use Symfonycasts\MicroMapper\MicroMapperInterface;
@@ -46,18 +43,20 @@ class SaleEntityToApiMapper implements MapperInterface
$dto->owner = $this->microMapper->map($entity->getOwner(), UserApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->ownerName = $entity->getOwner()?->getFirstName()." ".$entity->getOwner()?->getLastName();

$dto->partner = $this->microMapper->map($entity->getPartner(), PartnerApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->partnerName = $entity->getPartner()?->getName();
$dto->partnerType = $entity->getPartner()?->getType();
$dto->partnerIri = $this->microMapper->map($entity->getPartner(), PartnerApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);

$dto->product = $this->microMapper->map($entity->getProduct(), ProductApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->productName = $entity->getProduct()?->getName();
$dto->productIri = $this->microMapper->map($entity->getProduct(), ProductApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);

$dto->turnover = $entity->getTurnover();
$dto->profit = $entity->getProfit();
@@ -65,12 +64,6 @@ class SaleEntityToApiMapper implements MapperInterface
$dto->comment = $entity->getComment();
$dto->createdAt = $entity->getCreatedAt();

$dto->posts = array_map(function(Posting $posting) {
return $this->microMapper->map($posting, PostingApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
}, $entity->getPostings()->getValues());

return $dto;
}
}

+ 9
- 9
src/Mapper/TaskApiToEntityMapper.php Просмотреть файл

@@ -33,7 +33,7 @@ class TaskApiToEntityMapper implements MapperInterface
$dto = $from;
assert($dto instanceof TaskApi);

$assignedTo = $this->microMapper->map($dto->assignedTo, User::class, [
$assignedTo = $this->microMapper->map($dto->assignedToIri, User::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);

@@ -46,10 +46,10 @@ class TaskApiToEntityMapper implements MapperInterface
} else {
$user = $this->security->getUser();

if ($dto->product === null) {
if ($dto->productIri === null) {
throw new \Exception('Product missing');
}
$product = $this->microMapper->map($dto->product, Product::class, [
$product = $this->microMapper->map($dto->productIri, Product::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
assert($product instanceof Product);
@@ -75,17 +75,17 @@ class TaskApiToEntityMapper implements MapperInterface
$entity->setDescription($dto->description);
$entity->setDueAt($dto->dueAt);
$entity->setPartner(null);
if ($dto->partner !== null) {
assert($dto->partner instanceof PartnerApi);
$entity->setPartner($this->microMapper->map($dto->partner, Partner::class, [
if ($dto->partnerIri !== null) {
assert($dto->partnerIri instanceof PartnerApi);
$entity->setPartner($this->microMapper->map($dto->partnerIri, Partner::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]));
}

$entity->setContact(null);
if ($dto->contact !== null) {
assert($dto->contact instanceof ContactApi);
$entity->setContact($this->microMapper->map($dto->contact, Contact::class, [
if ($dto->contactIri !== null) {
assert($dto->contactIri instanceof ContactApi);
$entity->setContact($this->microMapper->map($dto->contactIri, Contact::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]));
}


+ 12
- 13
src/Mapper/TaskEntityToApiMapper.php Просмотреть файл

@@ -50,39 +50,38 @@ class TaskEntityToApiMapper implements MapperInterface
$dto->createdBy = $this->microMapper->map($entity->getCreatedBy(), UserApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->createdByName = $entity->getCreatedBy()?->getFirstName()." ".$entity->getCreatedBy()?->getLastName();
$dto->assignedTo = $this->microMapper->map($entity->getAssignedTo(), UserApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->assignedToName = $entity->getAssignedTo()?->getFirstName()." ".$entity->getAssignedTo()?->getLastName();
$dto->assignedToIri = $this->microMapper->map($entity->getAssignedTo(), UserApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->dueAt = $entity->getDueAt();

$dto->partnerType = null;
if ($entity->getPartner()) {
$dto->partner = $this->microMapper->map($entity->getPartner(), PartnerApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->partnerName = $entity->getPartner()?->getName();
$dto->partnerType = $entity->getPartner()?->getType();
$dto->partnerIri = $this->microMapper->map($entity->getPartner(), PartnerApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
}

if ($entity->getContact() !== null) {
$dto->contact = $this->microMapper->map($entity->getContact(), ContactApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->contactName = $entity->getContact()?->getFirstName()." ".$entity->getContact()?->getLastName();
$dto->contactIri = $this->microMapper->map($entity->getContact(), ContactApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
}

$dto->product = $this->microMapper->map($entity->getProduct(), ProductApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->productName = $entity->getProduct()?->getName();

$dto->taskNotes = array_map(function(TaskNote $taskNote) {
return $this->microMapper->map($taskNote, TaskNoteApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
}, $entity->getTaskNotes()->getValues());
$dto->productIri = $this->microMapper->map($entity->getProduct(), ProductApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);

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


+ 2
- 2
src/Mapper/TaskNoteApiToEntityMapper.php Просмотреть файл

@@ -34,10 +34,10 @@ class TaskNoteApiToEntityMapper implements MapperInterface
} else {
$user = $this->security->getUser();
assert($user instanceof User);
if ($dto->task === null) {
if ($dto->taskIri === null) {
throw new \Exception('Task missing');
}
$task = $this->microMapper->map($dto->task, Task::class, [
$task = $this->microMapper->map($dto->taskIri, Task::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
assert($task instanceof Task);


+ 1
- 2
src/Mapper/TaskNoteEntityToApiMapper.php Просмотреть файл

@@ -41,9 +41,8 @@ class TaskNoteEntityToApiMapper implements MapperInterface
$dto->owner = $this->microMapper->map($entity->getOwner(), UserApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->ownerName = $entity->getOwner()?->getFirstName()." ".$entity->getOwner()?->getLastName();

$dto->task = $this->microMapper->map($entity->getTask(), TaskApi::class, [
$dto->taskIri = $this->microMapper->map($entity->getTask(), TaskApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);



+ 1
- 0
src/Mapper/UserEntityToApiMapper.php Просмотреть файл

@@ -44,6 +44,7 @@ class UserEntityToApiMapper implements MapperInterface
$dto->lastName = $entity->getLastName();
$dto->image = $entity->getImage();
$dto->imageUrl = $this->fileUrlService->getFileUrl($entity->getImage());
$dto->fullName = $entity->getFirstName() . " " . $entity->getLastName();

return $dto;
}


+ 2
- 2
src/Mapper/UserProductApiToEntityMapper.php Просмотреть файл

@@ -35,10 +35,10 @@ class UserProductApiToEntityMapper implements MapperInterface
$user = $this->security->getUser();
assert($user instanceof User);

if ($dto->product === null) {
if ($dto->productIri === null) {
throw new \Exception('Product missing');
}
$product = $this->microMapper->map($dto->product, Product::class, [
$product = $this->microMapper->map($dto->productIri, Product::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
assert($product instanceof Product);


+ 3
- 2
src/Mapper/UserProductEntityToApiMapper.php Просмотреть файл

@@ -40,12 +40,13 @@ class UserProductEntityToApiMapper implements MapperInterface
$dto->user = $this->microMapper->map($entity->getUser(), UserApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->userName = $entity->getUser()?->getFirstName()." ".$entity->getUser()?->getLastName();

$dto->product = $this->microMapper->map($entity->getProduct(), ProductApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);
$dto->productName = $entity->getProduct()?->getName();
$dto->productIri = $this->microMapper->map($entity->getProduct(), ProductApi::class, [
MicroMapperInterface::MAX_DEPTH => 1,
]);

$dto->createdAt = $entity->getCreatedAt();



+ 0
- 1
src/State/SaleSummaryStateProvider.php Просмотреть файл

@@ -69,7 +69,6 @@ class SaleSummaryStateProvider implements ProviderInterface
if (count($sales) > 0) {
$salesSummary = new SaleSummary($user->getId());
$salesSummary->owner = $this->microMapper->map($user, UserApi::class);
$salesSummary->ownerName = $user->getFirstName() . ' ' . $user->getLastName();
$salesSummary->turnover = 0;
$salesSummary->profit = 0;
foreach ($sales as $sale) {


Загрузка…
Отмена
Сохранить