Content Hub uses the Common Data Format (CDF) for communication data between the Content Hub storage service and the end-user client layer comprising all the applications connected to the hub. Content Hub uses the JSON format to serialize CDF. Every piece of data is typed to ease its indexing for search.
We recommend that the following items be consistent between non-Drupal websites and Content Hub:
- When building a connector to publish to Content Hub, we recommend that you rename the other system's attributes to match what Drupal expects. This is more important for attributes that are built into Drupal, such as
Title. Doing this helps ensure consistent naming across all systems, which is important for token usage.
- Dates should be expressed in the ISO 8601 format — for example,
2016-02-09T23:04:20-05:00. In PHP, use
date('Y-m-d H:i:s’). Using
2016-02-09 23:04:20, which is incorrect.
The most important piece of the common data structure is the array of entities it contains. Each entry is an unrestricted entity, allowing the transmission of heterogenous collections in a single file.
The following is an example of the
The elements of an entity are defined as the following:
- uuid - Each entity is identified by a required UUID. Each client application should map its internal storage to such UUID in order to allow data synchronization over time.
- type - An arbitrary string which may be used by the client side to determine the type of entity and trigger appropriate behavior. Examples include articles and products.
- created - The created date in ISO 8601 standard format.
- modified - The modified date in ISO 8601 standard format.
- origin - The UUID of the client application that originally created this entity and owns it. This can be useful on the client side to know if a client is allowed to perform actions such as editing an entity.
- attributes - Localizable collections of values keyed by the attribute name. Each attribute is typed so that it can be stored in Content Hub and indexed properly for search purposes.
- assets - A list of resources that are referenced in the attributes of the entity in the form of tokens.
urlpoints to the
Asset. Token strings will be replaced in every attribute that has an occurrence in their value.
Attributes can be single pieces of information, or can be passed as nested attributes. Nested attributes follow the Elasticsearch methodology for mapping.
- type - Any primitive data type, such as
reference. If the value is an array, the type should be wrapped accordingly (for example:
- value - An associative array, always keyed by language. Unlocalized data must contain the
undkey, which is the standard for undefined language data.
Content Hub uses custom paths to both access an entity's CDF and prevent conflicts with the default system path.
To access an entity's CDF, in your browser's address bar enter a URL similar to the following, where:
[site]is your website's domain name
[entity type]is the entity type
[entity id]is the entity's ID number
[site]/acquia-contenthub-cdf/[entity type]/[entity id]?_format=acquia_contenthub_cdf
For example, the following URL example would allow you access to a paragraph entity's CDF:
Modifying entities and the CDF with hooks
Content Hub provides hooks for modifying your website's entities and CDF, allowing you to improve syndication, and modifying view modes in your website's CDF to support custom rendering processes:
- Allow modules to modify the Drupal entity after conversion from CDF
- Allow modules to modify the CDF before it is sent to the Content Hub
- Allow modules to modify the CDF before converting to Drupal entity
- Allow modules to modify the Drupal entity before its normalization to CDF