Core: Error generating the doc when registering a non-entity class

Created on 11 Aug 2015  路  4Comments  路  Source: api-platform/core

Hi,

We would like to registeras a ressource, a class that is not an ORM entity class.
This is our use case :

  • We have a class of properties loaded with static arrays
  • We try to expose it as a ressource with custom operations
    resource.l10nutils.item_operation.timezone_custom_get:
        class:   "Dunglas\ApiBundle\Api\Operation\Operation"
        public:  false
        factory: [ "@api.operation_factory", "createItemOperation" ]
        arguments:
            -    "@resource.l10nutils"                  # Resource
            -    [ "GET" ]                              # Methods
            -    "/timezone"                            # Path
            -    "AppBundle:CustomL10nUtils:getTimeZone" # Controller
            -    "TimeZone"                             # Route name
            -    # Context (will be present in Hydra documentation)
                 "@type":       "hydra:Operation"
                 "hydra:title": "All TimeZone"
                 "returns":     "xmls:string"

    resource.l10nutils:
        parent:         "api.resource"
        arguments:      [ "AppBundle\\Entity\\Utils\\L10nUtils" ]
        calls:
            -   method:    "initItemOperations"
                arguments: [ [ "@resource.l10nutils.item_operation.timezone_custom_get" ] ]
        tags:      [ { name: "api.resource" } ]

We can call our custom operations but we have an error when accessing the doc :

CRITICAL - Uncaught PHP Exception Doctrine\ORM\Mapping\MappingException: "Class "AppBundle\Entity\Utils\L10nUtils" is not a valid entity or mapped super class." at /media/fxlan/git/api-pm/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappingException.php line 336 

Is there any way to accept non-entity classes ?

question

Most helpful comment

In 2.0 it works well with no ORM at all in a basic Model file. Just make sure you give getters and setters so that the PropertyAccessor can parse the Model, you'll have to add some custom data provider or controller on top of it ofc.

All 4 comments

@blt909 have you managed this issue? (cuz I faced the same problem)

Considering the structure of 1.0, I'd say this is not possible. Might be doable in 2.0 (perhaps needs some work...)

In 2.0 it works well with no ORM at all in a basic Model file. Just make sure you give getters and setters so that the PropertyAccessor can parse the Model, you'll have to add some custom data provider or controller on top of it ofc.

Fixed in v2 as pointed out by @soyuka

Was this page helpful?
0 / 5 - 0 ratings