Previously, all resources shared a common implementation of the system properties object, located in Contentful\Management\SystemProperties
. The issue with implementation was that in order to accommodate for all possible resources, the class was unnecessarily big and contained many nullable properties.
To fix this and make the handling of system properties more robust, now every resource declares a specific system properties class, which is enforced through strict typing in their corresponding ->getSystemProperties()
methods:
/** @var \Contentful\Management\SystemProperties\Entry $sys */
$sys = $entry->getSystemProperties();
/** @var \Contentful\Management\SystemProperties\Asset $sys */
$sys = $asset->getSystemProperties();
/** @var \Contentful\Management\SystemProperties\ContentType $sys */
$sys = $contentType->getSystemProperties();
The system properties objects will work just like before, but pay attention to two things:
- If you were type hinting against general
Contentful\Management\SystemProperties
class, you need to change that to something more specific. If you still need something generic, you can use the baseContentful\Core\Resource\SystemPropertiesInterface
, but be careful as it only defines thegetId()
andgetType()
methods. - Methods that conceptually did not belong to a resource's system properties will no longer exist. For instance, you will not find the
getPublishedAt()
method in theContentful\Management\SystemProperties\Space
class.
If implementing a custom mapper (for instance using the code generation capabilities) you need to upgrade your Mapper::map()
methods:
// Before
return $this->hydrate(...);
// After
return $this->hydrator->hydrate(...);
The parameters of the two functions are the same, so no change there is necessary.
The SDK now uses version 2 of the contentful/core
package. We encourage users to check its changelog and upgrade guide.