public function get(ServerRequest $request, array $data = [])
    {
        $data += ['entity' => null];

        foreach ($this->providers as $provider) {
            $check = $provider['callable'];
            $context = $check($request, $data);
            if ($context) {
                break;
            }
        }
        if (!isset($context)) {
            $context = new NullContext($request, $data);
        }
        if (!($context instanceof ContextInterface)) {
            throw new RuntimeException(sprintf(
                'Context providers must return object implementing %s. Got "%s" instead.',
                ContextInterface::class,
                getTypeName($context)
            ));
        }

        return $context;
    }
public function get(ServerRequest $request, array $data = [])
    {
        $data += ['entity' => null];

        foreach ($this->providers as $provider) {
            $check = $provider['callable'];
            $context = $check($request, $data);
            if ($context) {
                break;
            }
        }
        if (!isset($context)) {
            $context = new NullContext($request, $data);
        }
        if (!($context instanceof ContextInterface)) {
            throw new RuntimeException(sprintf(
                'Context providers must return object implementing %s. Got "%s" instead.',
                ContextInterface::class,
                getTypeName($context)
            ));
        }

        return $context;
    }
public function get ( ServerRequest $ request , array $ data = [ ] ) { $ data += [ 'entity' => null ] ; foreach ( $ this -> providers as $ provider ) { $ check = $ provider [ 'callable' ] ; $ context = $ check ( $ request , $ data ) ; if ( $ context ) { break ; } } if ( ! isset ( $ context ) ) { $ context = new NullContext ( $ request , $ data ) ; } if ( ! ( $ context instanceof ContextInterface ) ) { throw new RuntimeException ( sprintf ( 'Context providers must return object implementing %s. Got "%s" instead.' , ContextInterface :: class , getTypeName ( $ context ) ) ) ; } return $ context ; }
Find the matching context for the data.

If no type can be matched a NullContext will be returned.

@param \Cake\Http\ServerRequest $request Request instance.
@param array $data The data to get a context provider for.
@return \Cake\View\Form\ContextInterface Context provider.
@throws \RuntimeException when the context class does not implement the
ContextInterface.
Find the matching context for the data .