Cake\View\Helper\FormHelper::addContextProvider PHP Method

addContextProvider() public method

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.
public addContextProvider ( string $type, callable $check ) : void
$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 void
    public function addContextProvider($type, callable $check)
    {
        foreach ($this->_contextProviders as $i => $provider) {
            if ($provider['type'] === $type) {
                unset($this->_contextProviders[$i]);
            }
        }
        array_unshift($this->_contextProviders, ['type' => $type, 'callable' => $check]);
    }