for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Silverback API Components Bundle Project
*
* (c) Daniel West <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Silverback\ApiComponentsBundle\DataProvider\StateProvider;
use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProviderInterface;
use Ramsey\Uuid\Uuid;
use Silverback\ApiComponentsBundle\Entity\Component\Form;
use Silverback\ApiComponentsBundle\Form\Type\User\PasswordUpdateType;
/**
* @author Daniel West <[email protected]>
class FormStateProvider implements ProviderInterface
{
public function __construct(private readonly ProviderInterface $defaultProvider)
}
public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
$id = $uriVariables['id'];
if ('password_reset' === $id) {
$dummyFormComponent = new Form();
$dummyFormComponent->formType = PasswordUpdateType::class;
$refObject = new \ReflectionObject($dummyFormComponent);
$refProperty = $refObject->getProperty('id');
$refProperty->setValue($dummyFormComponent, Uuid::uuid4());
return $dummyFormComponent;
return $this->defaultProvider->provide($operation, $uriVariables, $context);