Comments (5)
I just found this comment in the serializer class, line 79 :
// classname may be detected for hydra api with @type key
I guess this explains our issue :)
from rest-client-sdk.
I do not have a great idea about this:
The fact is that the entity is really coupled with the url you use to make the call for now.
A solution could be to allow a callback function to be called to override the default conversion functionality, but it may be complex and lead to bugs and be very coupled with the library, so more BC.
Another solution is to implement a "kind of" inheritance system, like doctrine does but it may be really complex and add a lot of configuration.
If you have a better idea, I will gladly take it as you are more close to the code.
from rest-client-sdk.
I just pushed PR #56 , which is a proposal for the handling of abstract entities, let me know all the adjustments you'd like.
I added unit tests but I never used atoum before, my tests may not be 100% on par with your habits, just let me know.
from rest-client-sdk.
I reviewed you PR, but I think of a nice "quickfix" you can do right now in your code before we fixed it in the API:
You can just override the findBy
method like defined in the README
You won't benefit from all the magic behind like the cache system, but you can implement it easily yourself if you need it (you won't need it if you code is clean, but I know we do :) )
The implementation can be something like this:
public function findBy(array $params) {
// generate the path to call
$path = // ...
$data = $this->restClient->get($path);
$hydrator = $this->sdk->getModelHydrator();
$out = [];
foreact ($data as $item) {
$entityName = $item['@type'] === 'Bar' ? 'Foo\Bar' : 'Foo\Baz';
$out[] = $hydrator->hydrate($item, $entityName);
}
return $out;
}
from rest-client-sdk.
Fixed in v0.21.0.
from rest-client-sdk.
Related Issues (20)
- Persisting an entity with a ManyToOne relation does not convert related entity as IRI HOT 10
- Allow an ID instead of an IRI HOT 1
- Handle exceptions from API HOT 3
- paginated hydra collections support HOT 8
- More recent version of ocramius/proxy-manager HOT 5
- improve performance of related entities retrieval HOT 1
- Do not `PUT` if Unit of work returns an empty diff
- support of partial entities HOT 8
- Creating relation entities even when they aren't resources HOT 6
- page collection
- list available types
- Error if the setter does not exists
- Do not allow two `@Rest\Id` fields
- Proxy initializer function bug HOT 6
- Issue with `UnitOfWork` and query parameters
- Use property accessor
- Allow int as id in model
- DateTime : allow customer format
- DateTime : changing timezone
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rest-client-sdk.