class ResourceBuilder

ResourceBuilder class.

This class is responsible for populating PHP objects using data received from Contentful's API.

Methods

ResourceInterface|ResourceArray
build(array $data, ResourceInterface $resource = null)

Creates or updates an object using given data.

setDataMapperMatcher(string $type, callable $dataMapperMatcher = null)

Sets a callable which will receive raw data (the JSON payload converted to a PHP array) and will determine the FQCN for appropriate mapping of that resource.

Details

at line 47
ResourceInterface|ResourceArray build(array $data, ResourceInterface $resource = null)

Creates or updates an object using given data.

This method will overwrite properties of the $resource parameter.

Parameters

array $data The raw API data
ResourceInterface $resource A object if it needs to be updated, or null otherwise

Return Value

ResourceInterface|ResourceArray

at line 122
ResourceBuilder setDataMapperMatcher(string $type, callable $dataMapperMatcher = null)

Sets a callable which will receive raw data (the JSON payload converted to a PHP array) and will determine the FQCN for appropriate mapping of that resource.

Parameters

string $type The system type as defined in ResourceBuilder::getSystemType()
callable $dataMapperMatcher A valid callable

Return Value

ResourceBuilder