public static function createWithDefaults(array $providers = [])
    {
        $providers = [
            [
                'type' => 'orm',
                'callable' => function ($request, $data) {
                    if (is_array($data['entity']) || $data['entity'] instanceof Traversable) {
                        $pass = (new Collection($data['entity']))->first() !== null;
                        if ($pass) {
                            return new EntityContext($request, $data);
                        }
                    }
                    if ($data['entity'] instanceof EntityInterface) {
                        return new EntityContext($request, $data);
                    }
                    if (is_array($data['entity']) && empty($data['entity']['schema'])) {
                        return new EntityContext($request, $data);
                    }
                }
            ],
            [
                'type' => 'array',
                'callable' => function ($request, $data) {
                    if (is_array($data['entity']) && isset($data['entity']['schema'])) {
                        return new ArrayContext($request, $data['entity']);
                    }
                }
            ],
            [
                'type' => 'form',
                'callable' => function ($request, $data) {
                    if ($data['entity'] instanceof Form) {
                        return new FormContext($request, $data);
                    }
                }
            ],
        ] + $providers;

        return new static($providers);
    }
public static function createWithDefaults(array $providers = [])
    {
        $providers = [
            [
                'type' => 'orm',
                'callable' => function ($request, $data) {
                    if (is_array($data['entity']) || $data['entity'] instanceof Traversable) {
                        $pass = (new Collection($data['entity']))->first() !== null;
                        if ($pass) {
                            return new EntityContext($request, $data);
                        }
                    }
                    if ($data['entity'] instanceof EntityInterface) {
                        return new EntityContext($request, $data);
                    }
                    if (is_array($data['entity']) && empty($data['entity']['schema'])) {
                        return new EntityContext($request, $data);
                    }
                }
            ],
            [
                'type' => 'array',
                'callable' => function ($request, $data) {
                    if (is_array($data['entity']) && isset($data['entity']['schema'])) {
                        return new ArrayContext($request, $data['entity']);
                    }
                }
            ],
            [
                'type' => 'form',
                'callable' => function ($request, $data) {
                    if ($data['entity'] instanceof Form) {
                        return new FormContext($request, $data);
                    }
                }
            ],
        ] + $providers;

        return new static($providers);
    }
public static function createWithDefaults ( array $ providers = [ ] ) { $ providers = [ [ 'type' => 'orm' , 'callable' => function ( $ request , $ data ) { if ( is_array ( $ data [ 'entity' ] ) || $ data [ 'entity' ] instanceof Traversable ) { $ pass = ( new Collection ( $ data [ 'entity' ] ) ) -> first ( ) !== null ; if ( $ pass ) { return new EntityContext ( $ request , $ data ) ; } } if ( $ data [ 'entity' ] instanceof EntityInterface ) { return new EntityContext ( $ request , $ data ) ; } if ( is_array ( $ data [ 'entity' ] ) && empty ( $ data [ 'entity' ] [ 'schema' ] ) ) { return new EntityContext ( $ request , $ data ) ; } } ] , [ 'type' => 'array' , 'callable' => function ( $ request , $ data ) { if ( is_array ( $ data [ 'entity' ] ) && isset ( $ data [ 'entity' ] [ 'schema' ] ) ) { return new ArrayContext ( $ request , $ data [ 'entity' ] ) ; } } ] , [ 'type' => 'form' , 'callable' => function ( $ request , $ data ) { if ( $ data [ 'entity' ] instanceof Form ) { return new FormContext ( $ request , $ data ) ; } } ] , ] + $ providers ; return new static ( $ providers ) ; }
Create factory instance with providers "array", "form" and "orm".

@param array $providers Array of provider callables. Each element should
be of form `['type' => 'a-string', 'callable' => ..]`
@return \Cake\View\Form\ContextFactory
Create factory instance with providers array form and orm .