class Client extends Client

A Client is used to communicate the Contentful Delivery API.

A Client is only responsible for one Space. When access to multiple spaces 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

VERSION

Methods

__construct($token, string $spaceId, bool $preview = false, LoggerInterface $logger = null)

Client constructor.

array|object
request(string $method, string $path, array $options = [])

No description

from Client
getUserAgentAppName()

No description

getUserAgent()

No description

from Client
object|array
decodeJson(string $json)

No description

from Client
getAsset(string $id)

No description

getAssets(Query $query = null)

No description

getContentType(string $id)

No description

getContentTypes(Query $query = null)

No description

getEntry(string $id)

No description

getEntries(Query $query = null)

No description

getSpace()

No description

resolveLink(Link $link)

Resolve a link to it's resource.

reviveJson(string $json)

Revive JSON previously cached.

mixed
syncRequest(array $queryData)

Internal method for \Contentful\Delivery\Synchronization\Manager

bool
isPreview()

Returns true when using the Preview API

getSynchronizationManager()

Get an instance of the synchronization manager.

Details

at line 52
__construct($token, string $spaceId, bool $preview = false, LoggerInterface $logger = null)

Client constructor.

Parameters

$token
string $spaceId ID of the space used with this Client.
bool $preview True to use the Preview API.
LoggerInterface $logger

in Client at line 69
protected array|object request(string $method, string $path, array $options = [])

Parameters

string $method
string $path
array $options

Return Value

array|object

at line 66
protected getUserAgentAppName()

in Client at line 129
protected getUserAgent()

in Client at line 147
protected object|array decodeJson(string $json)

Parameters

string $json JSON encoded object or array

Return Value

object|array

Exceptions

RuntimeException On invalid JSON

at line 78
Asset getAsset(string $id)

Parameters

string $id

Return Value

Asset

at line 96
ResourceArray getAssets(Query $query = null)

Parameters

Query $query

Return Value

ResourceArray

at line 114
ContentType getContentType(string $id)

Parameters

string $id

Return Value

ContentType

at line 130
ResourceArray getContentTypes(Query $query = null)

Parameters

Query $query

Return Value

ResourceArray

at line 145
EntryInterface getEntry(string $id)

Parameters

string $id

Return Value

EntryInterface

at line 163
ResourceArray getEntries(Query $query = null)

Parameters

Query $query

Return Value

ResourceArray

at line 179
Space getSpace()

Return Value

Space

Resolve a link to it's resource.

Parameters

Link $link

Return Value

Asset|EntryInterface

Exceptions

InvalidArgumentException When encountering an unexpected link type.

at line 225
Asset|ContentType|DynamicEntry|Space|DeletedAsset|DeletedEntry|ResourceArray reviveJson(string $json)

Revive JSON previously cached.

Parameters

string $json

Return Value

Asset|ContentType|DynamicEntry|Space|DeletedAsset|DeletedEntry|ResourceArray

Exceptions

SpaceMismatchException When attemptiting to revive JSON belonging to a different space

at line 242
mixed syncRequest(array $queryData)

Internal method for \Contentful\Delivery\Synchronization\Manager

Parameters

array $queryData

Return Value

mixed

See also

\Contentful\Delivery\Synchronization\Manager

at line 257
bool isPreview()

Returns true when using the Preview API

Return Value

bool

See also

https://www.contentful.com/developers/docs/references/content-preview-api/#/reference Preview API Reference

at line 272
Manager getSynchronizationManager()

Get an instance of the synchronization manager.

Return Value

Manager

Exceptions

RuntimeException If this method is called while using the Preview API.

See also

https://www.contentful.com/developers/docs/concepts/sync/ Sync API