protected function RelationLinkManager::writeCache in Default Content 8
Writes the cache of relation links.
Parameters
array $context: Context from the normalizer/serializer operation.
Return value
array An array of typed data IDs keyed by corresponding relation URI. The keys are:
- 'entity_type_id'
- 'bundle'
- 'field_name'
The values for 'entity_type_id', 'bundle' and 'field_name' are strings.
Overrides RelationLinkManager::writeCache
File
- src/
LinkManager/ RelationLinkManager.php, line 26 - Contains \Drupal\defaultcontent\LinkManager\RelationLinkManager.
Class
Namespace
Drupal\defaultcontent\LinkManagerCode
protected function writeCache() {
$data = array();
foreach ($this->entityManager
->getDefinitions() as $entity_type_id => $entity_type) {
$reflection = new \ReflectionClass($entity_type
->getClass());
// We are only interested in importing content entities.
if ($reflection
->implementsInterface('\\Drupal\\Core\\Config\\Entity\\ConfigEntityInterface') || !$reflection
->hasMethod('baseFieldDefinitions')) {
continue;
}
foreach (array_keys($this->entityManager
->getBundleInfo($entity_type_id)) as $bundle) {
foreach ($this->entityManager
->getFieldDefinitions($entity_type_id, $bundle) as $field_name => $field_details) {
$relation_uri = $this
->getRelationUri($entity_type_id, $bundle, $field_name);
$data[$relation_uri] = array(
'entity_type' => $entity_type_id,
'bundle' => $bundle,
'field_name' => $field_name,
);
}
}
}
}