Client
class Client extends BaseClient implements ClientInterface, SynchronizationClientInterface, JsonDecoderClientInterface
A Client is used to communicate the Contentful Delivery API.
A Client is only responsible for one space and one environment. When access to multiple spaces or environments is required, create multiple Clients.
This class can be configured to use the Preview API instead of the Delivery API. This grants access to not yet published content.
Constants
| API_DELIVERY |
|
| API_PREVIEW |
|
| URI_DELIVERY |
The URI for the Delivery API. |
| URI_PREVIEW |
The URI for the Preview API. |
Methods
Client constructor.
Returns a string representation of the API currently in use.
No description
No description
No description
No description
{@inheritdoc}
{@inheritdoc}
{@inheritdoc}
Returns the resource pool currently in use.
Returns a single Asset object corresponding to the given ID.
Returns a single ContentType object corresponding to the given ID.
Returns a collection of ContentType objects wrapped in a ResourceArray instance.
Returns the Environment object corresponding to the one in use.
Returns a single Entry object corresponding to the given ID.
Returns a collection of Entry objects wrapped in a ResourceArray instance.
Resolve a link to its actual resource.
Resolves an array of links.
Parse a JSON string.
Returns true when using the Delivery API.
Returns true when using the Preview API.
Get an instance of the synchronization manager.
Internal method for the sync manager.
{@inheritdoc}
Details
at line 121
__construct(string $token, string $spaceId, string $environmentId = 'master', ClientOptions $options = \null)
Client constructor.
at line 150
string
getApi()
Returns a string representation of the API currently in use.
at line 158
string
getSpaceId()
at line 166
string
getEnvironmentId()
at line 174
ResourceBuilderInterface
getResourceBuilder()
at line 182
Parser
getRichTextParser()
at line 190
static protected
getSdkName()
{@inheritdoc}
at line 198
static protected
getPackageName()
{@inheritdoc}
at line 206
static protected
getApiContentType()
{@inheritdoc}
at line 216
ResourcePoolInterface
getResourcePool()
Returns the resource pool currently in use.
at line 240
Asset
getAsset(string $assetId, string $locale = \null)
Returns a single Asset object corresponding to the given ID.
at line 259
ResourceArray|Asset[]
getAssets(Query $query = \null)
Returns a collection of Asset objects wrapped in a ResourceArray instance.
at line 279
ContentType
getContentType(string $contentTypeId)
Returns a single ContentType object corresponding to the given ID.
at line 295
ResourceArray|ContentType[]
getContentTypes(Query $query = \null)
Returns a collection of ContentType objects wrapped in a ResourceArray instance.
at line 310
Environment
getEnvironment()
Returns the Environment object corresponding to the one in use.
at line 345
Entry
getEntry(string $entryId, string $locale = \null)
Returns a single Entry object corresponding to the given ID.
at line 364
ResourceArray|Entry[]
getEntries(Query $query = \null)
Returns a collection of Entry objects wrapped in a ResourceArray instance.
at line 384
Space
getSpace()
Returns the Space object corresponding to the one in use.
at line 400
ResourceInterface
resolveLink(Link $link, string $locale = \null)
Resolve a link to its actual resource.
at line 410
ResourceInterface[]
resolveLinkCollection(array $links, string $locale = \null)
Resolves an array of links.
A method implementing this may apply some optimizations to reduce the amount of necessary API calls.
at line 426
ResourceInterface|ResourceArray
parseJson(string $json)
Parse a JSON string.
at line 438
bool
isDeliveryApi()
Returns true when using the Delivery API.
at line 448
bool
isPreviewApi()
Returns true when using the Preview API.
at line 456
Manager
getSynchronizationManager()
Get an instance of the synchronization manager.
Note that with the Preview API only an initial sync gives valid results.
at line 464
array
syncRequest(array $queryData)
Internal method for the sync manager.
at line 474
request(string $method, string $uri, array $options = [])
{@inheritdoc}