Per https://api-platform.com/docs/core/data-persisters/#decorating-the-built-in-data-persisters, ApiPlatform\Core\DataPersister\ContextAwareDataPersisterInterface is used. When I attempted, I received an error and was advised to use ApiPlatform\Core\DataPersister\DataPersisterInterface. When doing so, all works at first, but return $this->decorated->supports($data, $context) results in an endless loop. Perhaps just change to return $data instanceof BlogPost;? If this is more than just a documentation issue, please either let me know so I will submit a bug issue or move it. Thanks!
namespace App\DataPersister;
use ApiPlatform\Core\DataPersister\ContextAwareDataPersisterInterface;
use App\Entity\User;
use Symfony\Component\Mailer\MailerInterface;
final class UserDataPersister implements ContextAwareDataPersisterInterface
{
private $decorated;
private $mailer;
public function __construct(ContextAwareDataPersisterInterface $decorated, MailerInterface $mailer)
{
$this->decorated = $decorated;
$this->mailer = $mailer;
}
public function supports($data, array $context = []): bool
{
return $this->decorated->supports($data, $context);
}
// ...
}
Per https://api-platform.com/docs/core/data-persisters/#decorating-the-built-in-data-persisters,
ApiPlatform\Core\DataPersister\ContextAwareDataPersisterInterface
is used. When I attempted, I received an error and was advised to useApiPlatform\Core\DataPersister\DataPersisterInterface
. When doing so, all works at first, butreturn $this->decorated->supports($data, $context)
results in an endless loop. Perhaps just change toreturn $data instanceof BlogPost;
? If this is more than just a documentation issue, please either let me know so I will submit a bug issue or move it. Thanks!