Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Unable to fetch hydrators after creating a new service #288

Closed
ingokasch opened this issue Feb 19, 2017 · 1 comment
Closed

Unable to fetch hydrators after creating a new service #288

ingokasch opened this issue Feb 19, 2017 · 1 comment
Labels
Milestone

Comments

@ingokasch
Copy link

While using Apigility 1.4.1 and ZF3 creating a new "Doctrine Connected" REST service based on an existing domain entity will cause and error saying "unable to fetch hydrators" on editing.

The service config:

<?php
return array(
    'service_manager' => array(
        'factories' => array(),
    ),
    'router' => array(
        'routes' => array(
            'my-api.rest.doctrine.user' => array(
                'type' => 'Segment',
                'options' => array(
                    'route' => '/user[/:user_id]',
                    'defaults' => array(
                        'controller' => 'MyApi\\V1\\Rest\\User\\Controller',
                    ),
                ),
            ),
        ),
    ),
    'zf-versioning' => array(
        'uri' => array(
            0 => 'my-api.rest.doctrine.user',
        ),
    ),
    'zf-rest' => array(
        'MyApi\\V1\\Rest\\User\\Controller' => array(
            'listener' => 'MyApi\\V1\\Rest\\User\\UserResource',
            'route_name' => 'my-api.rest.doctrine.user',
            'route_identifier_name' => 'user_id',
            'entity_identifier_name' => 'id',
            'collection_name' => 'user',
            'entity_http_methods' => array(
                0 => 'GET',
                1 => 'PATCH',
                2 => 'PUT',
                3 => 'DELETE',
            ),
            'collection_http_methods' => array(
                0 => 'GET',
                1 => 'POST',
            ),
            'collection_query_whitelist' => array(),
            'page_size' => 25,
            'page_size_param' => null,
            'entity_class' => 'User\\Entity\\User',
            'collection_class' => 'MyApi\\V1\\Rest\\User\\UserCollection',
            'service_name' => 'User',
        ),
    ),
    'zf-content-negotiation' => array(
        'controllers' => array(
            'MyApi\\V1\\Rest\\User\\Controller' => 'HalJson',
        ),
        'accept_whitelist' => array(),
        'content_type_whitelist' => array(),
        'accept-whitelist' => array(
            'MyApi\\V1\\Rest\\User\\Controller' => array(
                0 => 'application/vnd.my-api.v1+json',
                1 => 'application/hal+json',
                2 => 'application/json',
            ),
        ),
        'content-type-whitelist' => array(
            'MyApi\\V1\\Rest\\User\\Controller' => array(
                0 => 'application/vnd.my-api.v1+json',
                1 => 'application/json',
            ),
        ),
    ),
    'zf-hal' => array(
        'metadata_map' => array(
            'User\\Entity\\User' => array(
                'route_identifier_name' => 'user_id',
                'entity_identifier_name' => 'id',
                'route_name' => 'my-api.rest.doctrine.user',
                'hydrator' => 'MyApi\\V1\\Rest\\User\\UserHydrator',
            ),
            'MyApi\\V1\\Rest\\User\\UserCollection' => array(
                'entity_identifier_name' => 'id',
                'route_name' => 'my-api.rest.doctrine.user',
                'is_collection' => true,
            ),
        ),
    ),
    'zf-apigility' => array(
        'doctrine-connected' => array(
            'MyApi\\V1\\Rest\\User\\UserResource' => array(
                'object_manager' => 'doctrine.entitymanager.orm_default',
                'hydrator' => 'MyApi\\V1\\Rest\\User\\UserHydrator',
            ),
        ),
    ),
    'doctrine-hydrator' => array(
        'MyApi\\V1\\Rest\\User\\UserHydrator' => array(
            'entity_class' => 'User\\Entity\\User',
            'object_manager' => 'doctrine.entitymanager.orm_default',
            'by_value' => true,
            'strategies' => array(),
            'use_generated_hydrator' => true,
        ),
    ),
    'zf-content-validation' => array(
        'MyApi\\V1\\Rest\\User\\Controller' => array(
            'input_filter' => 'MyApi\\V1\\Rest\\User\\Validator',
        ),
    ),
    'input_filter_specs' => array(
        'MyApi\\V1\\Rest\\User\\Validator' => array(
            ...
        ),
    ),
);
@michalbundyra
Copy link
Member

@ingokasch I've tried reproduce it and I can't. I was using https://github.com/webimpress/zf3-apigility-doctrine with configured doctrine and example database. All seems to be fine. I've noticed another issue, also present on your configuration above:

    'zf-content-negotiation' => array(
        // ....
        'accept_whitelist' => array(),
        'content_type_whitelist' => array(),
        'accept-whitelist' => array(
            // ...
        ),
        'content-type-whitelist' => array(
            // ...

and then in interface we show wrong whitelists in Content Negotiation tab. I'm going to work on fix for it.
If you could try again please, maybe with my configured repository, to make sure, all is fine with your configuration. Let me know if you experience the same issue and steps to reproduce it. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants