Hi,
We would like to registeras a ressource, a class that is not an ORM entity class.
This is our use case :
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 ?
@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
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.