Comments (11)
Hey @dstuessy 🙂
Can you provide some more info, so we can try to understand your problem? I'm interested in what the expected result is compared to the actual result, and the different behavior you experience when using setInclude.
Contentful's API uses include=1 when no explicit parameter is defined, and the SDK should resolve links automatically, at the cost of an extra query, so using setInclude or not should yield the same result, with the underlying difference of having done more queries behind the scenes. Let me know your answers to my question above, so we can start debugging your issue 👍
from contentful.php.
Hi @dborsatto
Hm... maybe it's just a matter of me misreading the docs. haha
Here is what I expected to get:
{
"sys": {
"type": "Array"
},
"total": 1,
"skip": 0,
"limit": 100,
"items": [
{
"sys": {},
"fields": {
"title": "Cars",
"content": [
{
"sys": {
"type": "Link",
"linkType": "Entry",
"id": "_id"
}
},
{
"sys": {
"type": "Link",
"linkType": "Entry",
"id": "_id"
}
}
]
}
}
],
"includes": {
"Entry": [ {}, {} ]
}
}
but actually got this:
{
"sys": {
"type": "Array"
},
"total": 1,
"skip": 0,
"limit": 100,
"items": [
{
"sys": {},
"fields": {
"title": "Cars",
"content": [
{
"sys": {
"type": "Link",
"linkType": "Entry",
"id": "_id"
}
},
{
"sys": {
"type": "Link",
"linkType": "Entry",
"id": "_id"
}
}
]
}
}
]
}
Using https://cdn.contentful.com/spaces/{my_space}/entries?access_token={my_token}&content_type={type}&fields.title=Cars&include=2
with a cURL request, seems to give me the former, though.
from contentful.php.
That looks weird indeed.
What do you say about opening a support ticket on contentul.com? So I can better take a look at your issue and see what we can find out 🙂 Please reference this Github issue 👍
from contentful.php.
Hi @dborsatto :)
Sorry for the extremely late reply. I'll open a support ticket with this github issue as a reference!
from contentful.php.
@dborsatto any update on this? As this is a public SDK it would be great to link the outcome of the support ticket as well as any corresponding commits and merges as the documentation is severely lacking. Thanks!
from contentful.php.
Hey @M-Porter,
Daniel created a support ticket, but then he never replied with some info I asked, so the ticket was archived.
For this case, are you having a similar issue? To be honest I can't fully understand the initial problem because the examples were about JSON, whereas the SDK should work as an abstraction thus making the underlying JSON irrelevant. Do you have any input on the topic?
Cheers,
Davide
from contentful.php.
Hey,
I'm closing this (again). If you have any more questions, don't hesitate to reach out.
Davide
from contentful.php.
The returned ResourceArray
does not seem to include the "includes" array that both the API and the Javascript SDK return.
from contentful.php.
@officialbalazs The SDK handles the includes
array internally and does not directly expose it. When you try to access those resources (through the original entry) the SDK will know that they've already been preloaded, and will not make further requests.
from contentful.php.
Aha - makes sense. Is there a way to expose that array?
It would save us from having to make subsequent requests to our API after fetching the original entry.
from contentful.php.
You can not access it, but as I said, there will be no extra API requests.
If the includes
array contains an entry/asset, the SDK will not make extra requests when trying to fetch it (both when accessing it from another entry with something like $blogPost->getImage()
or when calling $client->getAsset($assetThatWasAlreadyFetchedId)
), because it will keep a copy of the resource in memory and use it instead of calling the API.
You can call $client->getMessages()
for accessing a list of the API requests that have been made (it returns a list of Contentful\Core\Api\Message
objects), and see for yourself that there shouldn't be extra API calls.
from contentful.php.
Related Issues (20)
- 503 between bytes timeout response - Sync API HOT 3
- Potential segfault? HOT 5
- BaseClient::messages memory exhaustion HOT 3
- Allow specifying timeouts for API requests
- Support for Tags HOT 3
- Support for HTML Serializing of Rich Text fields HOT 2
- Empty Paragraph Node HOT 2
- Filtering not working on preview API HOT 3
- Version 6.2.0 contains BC breaks HOT 6
- Library not compatible with Google Auth because of not supporting PSR Cache in version 2 HOT 3
- Nested assets not returned for $entry->all(); HOT 3
- Serializable interface deprecated in PHP 8.1 HOT 3
- Contentful Delivery $setLocale * not working as expected HOT 6
- Deprecation warnings in PHP 8.1 HOT 13
- Soft Line Returns Not Rendered to HTML HOT 3
- Client::getEntries() cache does not work properly with different locales HOT 2
- psr/log require mismatch with Magento 2.4.4-p2 HOT 5
- PHP 8.2 HOT 1
- Doesn't return content, links, images and fields when serializing HOT 1
- I have a problem when updating php 8 that is defining the return type with Contentful\Delivery\Resource\Entry
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 contentful.php.