Coder Social home page Coder Social logo

Comments (5)

dunglas avatar dunglas commented on July 28, 2024

id is hardcoded in some part of the bundle. As a property called @id is required by JSON-LD, I can sleep with the requirement of having a public $id property or a getId() method defined. Just consider it as the value of @id.

There is nothing preventing to create getId() method even if it's not the property name used by Doctrine. And some edge cases such as composed primary keys are not compatible with JSON-LD anyway.

I don't want to create a hard dependency against Doctrine (we currently use the bundle with other data providers such as Elastic Search, web services...). If you want to make the method used configurable, an entry in https://github.com/dunglas/DunglasApiBundle/blob/master/Mapping/ClassMetadata.php looks better to me.

from core.

MLKiiwy avatar MLKiiwy commented on July 28, 2024

Yes, my PR introduce an hard dependancy with doctrine. I'm looking for a better solution to remove that

from core.

dunglas avatar dunglas commented on July 28, 2024

My proposal:

  1. create a $identifier property in https://github.com/dunglas/DunglasApiBundle/blob/master/Mapping/ClassMetadata.php and in the relative interface with a default value being id
  2. create a DoctrineIdentifierLoader in https://github.com/dunglas/DunglasApiBundle/tree/master/Mapping/Loader populating that property using your code
  3. load the new loader only if Doctrine ORM is enable (in Resources/config/doctrine_orm.xml).
  4. in the IriConverter class (and probably in other part of the bundle), use that metadata

What do you think?

from core.

MLKiiwy avatar MLKiiwy commented on July 28, 2024

I think your solution is better and remove the dependancy with doctrine.
I write the code and do a PR this afternoon if it's ok ;)

from core.

dunglas avatar dunglas commented on July 28, 2024

Perfect :)

from core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.