gregorybesson / ApigilityFuse

Apigility + Doctrine + oAuth2Doctrine + ZfcUser
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Add another Entity #1

Open ghost opened 8 years ago

ghost commented 8 years ago

I want to know how to add a new entity , as soon as I add a new entity , it is found in the" doctrine connected" but there is an error during creation ( the class does not exist).

My doctrine settings


'doctrine' => array(
        'connection' => array(
            'orm_default' => array(
                'driverClass' => 'Doctrine\\DBAL\\Driver\\PDOPgSql\\Driver',
                'params' => array(
                    'host' => 'localhost',
                    'user' => 'pierre',
                    'password' => '***',
                    'port' => '5432',
                    'dbname' => 'zf',
                ),
            ),
        ),
        'driver' => array(
            'lanekeep_driver' => array(
                'class' => 'Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver',
                'cache' => 'array',
                'paths' => array(
                    0 => __DIR__ .  '/../../module/Pierre/src/Pierre/Entity',
                ),
            ),
            'orm_default' => array(
                'drivers' => array(
                    'Pierre\\Entity' => 'lanekeep_driver',
                ),
            ),
        ),
gregorybesson commented 8 years ago

@Piiierre6 : Did you create your Pierre\Entity class ? See some examples here : https://github.com/gregorybesson/PlaygroundGame/tree/develop/src/PlaygroundGame/Entity

You create your entity class with annotations on your properties, and you declare the entity in your config.

Tell me if you need more insights

ghost commented 8 years ago

Thank you for your answer , I didn't declare my Entity class

I have a small question, I create the doctrine connected , I would like to find my objects by ZipCode, and not by ID.

I try with QueryBuilder Doctrine but I did not configure my files

 'router' => array(
        'routes' => array(
            'pierre.rest.doctrine.pdl' => array(
                'type' => 'Segment',
                'options' => array(
                    'route' => '/pdl[/:pdl_id]',
                    'defaults' => array(
                        'controller' => 'Pierre\\V1\\Rest\\Pdl\\Controller',
                    ),
                ),
            ),
            'codepostal' => array(
                'type' => 'Segment',
                'options' => array(
                    'route' => '/pdl/cp[/:pdl_codepostal]',
                    'defaults' => array(
                        'controller' => 'Pierre\\V1\\Rest\\Pdl\\CodePostalController',
                    ),
                ),
            ),
        ),
    ),
    'zf-versioning' => array(
        'uri' => array(
            0 => 'pierre.rest.doctrine.pdl',
        ),
    ),
    'zf-doctrine-querybuilder-orderby-orm' => array(
        'invokables' => array(
            'field' => 'ZF\\Doctrine\\QueryBuilder\\OrderBy\\ORM\\Field',
        ),
    ),
    'zf-doctrine-querybuilder-filter-orm' => array(
        'invokables' => array(
            'eq' => 'ZF\\Doctrine\\QueryBuilder\\Filter\\ORM\\Equals',
        ),
    ),
    'zf-rest' => array(
        'Pierre\\V1\\Rest\\Pdl\\Controller' => array(
            'listener' => 'Pierre\\V1\\Rest\\Pdl\\PdlResource',
            'route_name' => 'pierre.rest.doctrine.pdl',
            'route_identifier_name' => 'pdl_id',
            'entity_identifier_name' => 'id',
            'collection_name' => 'pdl',
            'entity_http_methods' => array(
                0 => 'GET',
                1 => 'PATCH',
                2 => 'PUT',
                3 => 'DELETE',
            ),
            'collection_http_methods' => array(
                0 => 'GET',
                1 => 'POST',
            ),
            'collection_query_whitelist' => array(
                0 => 'codepostalC',
            ),
            'page_size' => 25,
            'page_size_param' => null,
            'entity_class' => 'Application\\Entity\\Pdl',
            'collection_class' => 'Pierre\\V1\\Rest\\Pdl\\PdlCollection',
            'service_name' => 'Pdl',
        ),
        'Pierre\\V1\\Rest\\Pdl\\CodePostalController' => array(
            'listener' => 'Pierre\\V1\\Rest\\Pdl\\PdlResource',
            'route_name' => 'pierre.rest.doctrine.pdl',
            'route_identifier_name' => 'pdl_codepostal',
            'entity_identifier_name' => 'codepostalC',
            'collection_name' => 'pdl',
            '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' => 'Application\\Entity\\Pdl',
            'collection_class' => 'Pierre\\V1\\Rest\\Pdl\\PdlCollection',
            'service_name' => 'Pdl',
        ),
    ),
    'zf-content-negotiation' => array(
        'controllers' => array(
            'Pierre\\V1\\Rest\\Pdl\\Controller' => 'HalJson',
            'Pierre\\V1\\Rest\\Pdl\\CodePostalController' => 'HalJson',
        ),
        'accept-whitelist' => array(
            'Pierre\\V1\\Rest\\Pdl\\Controller' => array(
                0 => 'application/vnd.pierre.v1+json',
                1 => 'application/hal+json',
                2 => 'application/json',
            ),
            'Pierre\\V1\\Rest\\Pdl\\CodePostalController' => array(
                0 => 'application/vnd.pierre.v1+json',
                1 => 'application/hal+json',
                2 => 'application/json',
            ),
        ),
        'content-type-whitelist' => array(
            'Pierre\\V1\\Rest\\Pdl\\Controller' => array(
                0 => 'application/json',
            ),
            'Pierre\\V1\\Rest\\Pdl\\CodePostalController' => array(
                0 => 'application/vnd.pierre.v1+json',
                1 => 'application/json',
            ),
        ),
    ),
    'zf-hal' => array(
        'metadata_map' => array(
            'Application\\Entity\\Pdl' => array(
                'route_identifier_name' => 'pdl_id',
                'entity_identifier_name' => 'id',
                'route_name' => 'pierre.rest.doctrine.pdl',
                'hydrator' => 'Pierre\\V1\\Rest\\Pdl\\PdlHydrator',
            ),
            'Pierre\\V1\\Rest\\Pdl\\PdlCollection' => array(
                'entity_identifier_name' => 'id',
                'route_name' => 'pierre.rest.doctrine.pdl',
                'is_collection' => true,
            ),
        ),
    ),
    'zf-apigility' => array(
        'doctrine-connected' => array(
            'Pierre\\V1\\Rest\\Pdl\\PdlResource' => array(
                'object_manager' => 'doctrine.entitymanager.orm_default',
                'hydrator' => 'Pierre\\V1\\Rest\\Pdl\\PdlHydrator',
            ),
        ),
    ),
    'doctrine-hydrator' => array(
        'Pierre\\V1\\Rest\\Pdl\\PdlHydrator' => array(
            'entity_class' => 'Application\\Entity\\Pdl',
            'object_manager' => 'doctrine.entitymanager.orm_default',
            'by_value' => true,
            'strategies' => array(),
            'use_generated_hydrator' => true,
        ),
    ),
    'zf-content-validation' => array(
        'Pierre\\V1\\Rest\\Pdl\\Controller' => array(
            'input_filter' => 'Pierre\\V1\\Rest\\Pdl\\Validator',
        ),
        'Pierre\\V1\\Rest\\Pdl\\CodePostalController' => array(
            'input_filter' => 'Pierre\\V1\\Rest\\Pdl\\Validator',
        ),
    ),

Thanks :)