class FormStateValueResolver in MongoDB 8.2
Yields a form_state argument for FormStateInterface $formState arguments.
This resolver supports form methods with a FormStateInterface argument regardless of its name.
Hierarchy
- class \Drupal\mongodb_watchdog\Controller\ArgumentResolver\FormStateValueResolver implements \Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface
Expanded class hierarchy of FormStateValueResolver
1 string reference to 'FormStateValueResolver'
- mongodb_watchdog.services.yml in modules/
mongodb_watchdog/ mongodb_watchdog.services.yml - modules/mongodb_watchdog/mongodb_watchdog.services.yml
1 service uses FormStateValueResolver
File
- modules/
mongodb_watchdog/ src/ Controller/ ArgumentResolver/ FormStateValueResolver.php, line 16
Namespace
Drupal\mongodb_watchdog\Controller\ArgumentResolverView source
class FormStateValueResolver implements ArgumentValueResolverInterface {
const NAME_LEGACY = 'form_state';
/**
* {@inheritdoc}
*/
public function supports(Request $request, ArgumentMetadata $argument) {
$argumentInterfaceMatches = $argument
->getType() === FormStateInterface::class;
$requestAttributeExists = $request->attributes
->has(static::NAME_LEGACY);
return $argumentInterfaceMatches || $requestAttributeExists;
}
/**
* {@inheritdoc}
*/
public function resolve(Request $request, ArgumentMetadata $argument) {
$formState = $request->attributes
->has(static::NAME_LEGACY) ? $request->attributes
->get(static::NAME_LEGACY) : NULL;
(yield $formState);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FormStateValueResolver:: |
constant | |||
FormStateValueResolver:: |
public | function | ||
FormStateValueResolver:: |
public | function |