Factory for getting form context instance based on provided data.
array<string, array>
Context providers.
Constructor.
Add a new context type.
Create factory instance with providers "array", "form" and "orm".
Find the matching context for the data.
__construct(array $providers = [])
Constructor.
array
$providers optional Array of provider callables. Each element should be of form ['type' => 'a-string', 'callable' => ..]
addProvider(string $type, callable $check): $this
Add a new context type.
Form context types allow FormHelper to interact with data providers that come from outside CakePHP. For example if you wanted to use an alternative ORM like Doctrine you could create and connect a new context class to allow FormHelper to read metadata from doctrine.
string
$type The type of context. This key can be used to overwrite existing providers.
callable
$check A callable that returns an object when the form context is the correct type.
$this
createWithDefaults(array $providers = []): static
Create factory instance with providers "array", "form" and "orm".
array
$providers optional Array of provider callables. Each element should be of form ['type' => 'a-string', 'callable' => ..]
static
get(Cake\Http\ServerRequest $request, array<string, mixed> $data = []): Cake\View\Form\ContextInterface
Find the matching context for the data.
If no type can be matched a NullContext will be returned.
Cake\Http\ServerRequest
$request Request instance.
array<string, mixed>
$data optional The data to get a context provider for.
Cake\View\Form\ContextInterface
RuntimeException
Context providers.
array<string, array>
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.4/class-Cake.View.Form.ContextFactory.html