class EnvironmentProxy

EnvironmentProxy class.

This class works as a lazy reference to an environment resource. You can use it for most environment-related needs, such as fetching entries, assets and content types, or creating them (attaching them to this space).

To access this class, you can use the convenience method found in a client object.

$environment = $client->getEnvironmentProxy($spaceId, $environmentId);

The methods provided are very similar to the getX() methods you will find in an actual environment resource object. The main difference is that when fetching a environment resource, you will actually call the API, whereas with this proxy, you're just holding a reference to a certain environment. This is the reason why in most situations you should prefer using an EnvironmentProxy rather than an environment resource.

// Only the entries query will be made
$environment = $client->getEnvironmentProxy($spaceId, $environmentId);
$entries = $environment->getEntries();

// Two queries will be made
$environment = $client->getEnvironment($spaceId, $environmentId);
$entries = $environment->getEntries();

Traits

EnvironmentProxyExtension trait.

Properties

Client $client from EnvironmentProxyExtension

Methods

getSpaceId()

{@inheritdoc}

getEnvironmentId()

{@inheritdoc}

getAsset(string $assetId)

Returns an Asset resource.

ResourceArray
getAssets(Query $query = null)

Returns a ResourceArray object which contains Asset resources.

getContentType(string $contentTypeId)

Returns a ContentType resource.

ResourceArray
getContentTypes(Query $query = null)

Returns a ResourceArray object which contains ContentType resources.

getPublishedContentType(string $contentTypeId)

Returns a published ContentType resource.

ResourceArray
getPublishedContentTypes(Query $query = null)

Returns a ResourceArray object which contains published ContentType resources.

getContentTypeSnapshot(string $contentTypeId, string $snapshotId)

Returns a ContentTypeSnapshot resource.

ResourceArray
getContentTypeSnapshots(string $contentTypeId, Query $query = null)

Returns a ResourceArray object which contains ContentTypeSnapshot resources.

getEditorInterface(string $contentTypeId)

Returns an EditorInterface resource.

getEntry(string $entryId)

Returns an Entry resource.

ResourceArray
getEntries(Query $query = null)

Returns a ResourceArray object which contains Entry resources.

getEntrySnapshot(string $entryId, string $snapshotId)

Returns a EntrySnapshot resource.

ResourceArray
getEntrySnapshots(string $entryId, Query $query = null)

Returns a ResourceArray object which contains EntrySnapshot resources.

getExtension(string $extensionId)

Returns an Extension resource.

ResourceArray
getExtensions()

Returns a ResourceArray object containing Extension resources.

getLocale(string $localeId)

Returns a Locale resource.

ResourceArray
getLocales()

Returns a ResourceArray object containing Locale resources.

__construct(Client $client, string $spaceId, string $environmentId)

No description

getSpaceProxy()

Returns a proxy to a space resource.

create(CreatableInterface $resource, string $resourceId = '', ResourceInterface|string[] $parameters = [])

Persist a new resource in Contentful.

resolveLink(Link $link, array $parameters = [])

Resolves a Contentful link scoped to the current space and environment.

toResource()

Returns the Environment resource which corresponds to this proxy.

Details

at line 82
protected getSpaceId()

{@inheritdoc}

at line 90
protected getEnvironmentId()

{@inheritdoc}

Asset getAsset(string $assetId)

Returns an Asset resource.

Parameters

string $assetId

Return Value

Asset

See also

https://www.contentful.com/developers/docs/references/content-management-api/#/reference/assets/asset

ResourceArray getAssets(Query $query = null)

Returns a ResourceArray object which contains Asset resources.

Parameters

Query $query

Return Value

ResourceArray

See also

https://www.contentful.com/developers/docs/references/content-management-api/#/reference/assets/assets-collection

ContentType getContentType(string $contentTypeId)

Returns a ContentType resource.

Parameters

string $contentTypeId

Return Value

ContentType

See also

https://www.contentful.com/developers/docs/references/content-management-api/#/reference/content-types/content-type

ResourceArray getContentTypes(Query $query = null)

Returns a ResourceArray object which contains ContentType resources.

Parameters

Query $query

Return Value

ResourceArray

See also

https://www.contentful.com/developers/docs/references/content-management-api/#/reference/content-types/content-type-collection

ContentType getPublishedContentType(string $contentTypeId)

Returns a published ContentType resource.

Parameters

string $contentTypeId

Return Value

ContentType

See also

https://www.contentful.com/developers/docs/references/content-management-api/#/reference/content-types/activated-content-type-collection

ResourceArray getPublishedContentTypes(Query $query = null)

Returns a ResourceArray object which contains published ContentType resources.

Parameters

Query $query

Return Value

ResourceArray

See also

https://www.contentful.com/developers/docs/references/content-management-api/#/reference/content-types/activated-content-type-collection

ContentTypeSnapshot getContentTypeSnapshot(string $contentTypeId, string $snapshotId)

Returns a ContentTypeSnapshot resource.

Parameters

string $contentTypeId
string $snapshotId

Return Value

ContentTypeSnapshot

See also

https://www.contentful.com/developers/docs/references/content-management-api/#/reference/snapshots/content-type-snapshot

ResourceArray getContentTypeSnapshots(string $contentTypeId, Query $query = null)

Returns a ResourceArray object which contains ContentTypeSnapshot resources.

Parameters

string $contentTypeId
Query $query

Return Value

ResourceArray

See also

https://www.contentful.com/developers/docs/references/content-management-api/#/reference/snapshots/content-type-snapshots-collection

EditorInterface getEditorInterface(string $contentTypeId)

Returns an EditorInterface resource.

Parameters

string $contentTypeId

Return Value

EditorInterface

See also

https://www.contentful.com/developers/docs/references/content-management-api/#/reference/editor-interface

Entry getEntry(string $entryId)

Returns an Entry resource.

Parameters

string $entryId

Return Value

Entry

See also

https://www.contentful.com/developers/docs/references/content-management-api/#/reference/entries/entry

ResourceArray getEntries(Query $query = null)

Returns a ResourceArray object which contains Entry resources.

Parameters

Query $query

Return Value

ResourceArray

See also

https://www.contentful.com/developers/docs/references/content-management-api/#/reference/entries/entries-collection

EntrySnapshot getEntrySnapshot(string $entryId, string $snapshotId)

Returns a EntrySnapshot resource.

Parameters

string $entryId
string $snapshotId

Return Value

EntrySnapshot

See also

https://www.contentful.com/developers/docs/references/content-management-api/#/reference/snapshots/entry-snapshot

ResourceArray getEntrySnapshots(string $entryId, Query $query = null)

Returns a ResourceArray object which contains EntrySnapshot resources.

Parameters

string $entryId
Query $query

Return Value

ResourceArray

See also

https://www.contentful.com/developers/docs/references/content-management-api/#/reference/snapshots/entry-snapshots-collection

Extension getExtension(string $extensionId)

Returns an Extension resource.

Parameters

string $extensionId

Return Value

Extension

See also

https://www.contentful.com/developers/docs/references/content-management-api/#/reference/ui-extensions/extension

ResourceArray getExtensions()

Returns a ResourceArray object containing Extension resources.

Return Value

ResourceArray

See also

https://www.contentful.com/developers/docs/references/content-management-api/#/reference/ui-extensions/extensions-collection

Locale getLocale(string $localeId)

Returns a Locale resource.

Parameters

string $localeId

Return Value

Locale

See also

https://www.contentful.com/developers/docs/references/content-management-api/#/reference/locales/locale

ResourceArray getLocales()

Returns a ResourceArray object containing Locale resources.

Return Value

ResourceArray

See also

https://www.contentful.com/developers/docs/references/content-management-api/#/reference/locales/locale-collection

at line 72
__construct(Client $client, string $spaceId, string $environmentId)

Parameters

Client $client
string $spaceId
string $environmentId

at line 101
SpaceProxy getSpaceProxy()

Returns a proxy to a space resource.

Useful for all space-scoped operations.

Return Value

SpaceProxy

at line 117
create(CreatableInterface $resource, string $resourceId = '', ResourceInterface|string[] $parameters = [])

Persist a new resource in Contentful.

This is a convenience method which just forwards to Client::create(), but setting the space and environment keys to the current space and environment IDs in the parameters array.

Parameters

CreatableInterface $resource
string $resourceId
ResourceInterface|string[] $parameters

See also

\Contentful\Management\Client::create()

Resolves a Contentful link scoped to the current space and environment.

Parameters

Link $link
array $parameters

Return Value

ResourceInterface

at line 150
Environment toResource()

Returns the Environment resource which corresponds to this proxy.

Return Value

Environment

See also

https://www.contentful.com/developers/docs/references/content-management-api/#/reference/environments/environment