ContextFactory
    
            
            in package
            
        
    
    
    
Factory for getting form context instance based on provided data.
Table of Contents
Properties
- $providers : array<string, array<string|int, mixed>>
- Context providers.
Methods
- __construct() : mixed
- Constructor.
- addProvider() : $this
- Add a new context type.
- createWithDefaults() : static
- Create factory instance with providers "array", "form" and "orm".
- get() : ContextInterface
- Find the matching context for the data.
Properties
$providers
Context providers.
    protected
        array<string, array<string|int, mixed>>
    $providers
     = []
    
    
    
    
Methods
__construct()
Constructor.
    public
                    __construct([array<string|int, mixed> $providers = [] ]) : mixed
    Parameters
- $providers : array<string|int, mixed> = []
- 
                    Array of provider callables. Each element should be of form ['type' => 'a-string', 'callable' => ..]
addProvider()
Add a new context type.
    public
                    addProvider(string $type, callable $check) : $this
    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.
Parameters
- $type : string
- 
                    The type of context. This key can be used to overwrite existing providers. 
- $check : callable
- 
                    A callable that returns an object when the form context is the correct type. 
Return values
$thiscreateWithDefaults()
Create factory instance with providers "array", "form" and "orm".
    public
            static        createWithDefaults([array<string|int, mixed> $providers = [] ]) : static
    Parameters
- $providers : array<string|int, mixed> = []
- 
                    Array of provider callables. Each element should be of form ['type' => 'a-string', 'callable' => ..]
Return values
staticget()
Find the matching context for the data.
    public
                    get(ServerRequest $request[, array<string, mixed> $data = [] ]) : ContextInterface
    If no type can be matched a NullContext will be returned.
Parameters
- $request : ServerRequest
- 
                    Request instance. 
- $data : array<string, mixed> = []
- 
                    The data to get a context provider for. 
Tags
Return values
ContextInterface —Context provider.