Это хз, еше вспомнил момент: вроде вторая сущность тоже должна быть ресурсом платформы. Но это не точно.
Она ресурс тоже...
...
#[ApiResource(
collectionOperations: [
'get',
'post',
],
itemOperations: [
'get',
'put',
'delete'
],
denormalizationContext: ['groups' => [Group::PROVIDER_ACCOUNT]],
normalizationContext: ['groups' => [Group::PROVIDER_ACCOUNT]],
)]
...
class ProviderAccount
{
use EntityCreatedTrait;
use EntityUpdatedTrait;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: Types::SMALLINT, options: ['unsigned' => true])]
#[Groups([Group::PROVIDER_ACCOUNT])]
private ?int $id = null;
/**
* @var Collection<MerchantAccount>
*/
#[ORM\OneToMany(mappedBy: 'providerAccount', targetEntity: MerchantAccount::class, cascade: ['persist'])]
#[Groups([Group::PROVIDER_ACCOUNT])]
private Collection $wallets;
public function __construct()
{
$this->wallets = new ArrayCollection();
}
public function getWallets(): Collection
{
return $this->wallets;
}
public function setWallets($wallets): self
{
$this->wallets = ($wallets instanceof Collection) ? $wallets : new ArrayCollection($wallets);
return $this;
}
public function addWallet(MerchantAccount $wallet): self
{
if (!$this->wallets->contains($wallet)) {
$this->wallets->add($wallet);
}
return $this;
}
public function removeWallet(MerchantAccount $wallet): self
{
if ($this->wallets->contains($wallet)) {
$this->wallets->removeElement($wallet);
}
return $this;
}
}
...
#[ApiResource(
itemOperations: ['get', 'put'],
subresourceOperations: [
'merchant_orders_get_subresource' => [
'method' => 'GET',
'path' => '/merchant_orders',
'controller' => 'App\Controller\Common\Api\Admin\Entity\MerchantOrder\GetAllActionClass'
]
],
denormalizationContext: ['groups' => [Group::MERCHANT_ACCOUNT, Group::PROVIDER_ACCOUNT]],
normalizationContext: ['groups' => [Group::MERCHANT_ACCOUNT, Group::PROVIDER_ACCOUNT], 'disable_type_enforcement' => true]
)]
...
class MerchantAccount
{
use EntityCreatedTrait;
use EntityUpdatedTrait;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: Types::INTEGER)]
#[Groups([Group::PROVIDER_ACCOUNT, Group::MERCHANT_ACCOUNT, Group::GATEWAY, Group::COMMISSION, Group::HOLD])]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'wallets', targetEntity: ProviderAccount::class)]
#[Groups([Group::MERCHANT_ACCOUNT, Group::PROVIDER_ACCOUNT])]
private ?ProviderAccount $providerAccount = null;
...
public function getProviderAccount(): ?ProviderAccount
{
return $this->providerAccount;
}
public function setProviderAccount(?ProviderAccount $providerAccount): self
{
$this->providerAccount = $providerAccount;
return $this;
}
...
}