protected function RelationLinkManager::writeCache in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/rest/src/LinkManager/RelationLinkManager.php \Drupal\rest\LinkManager\RelationLinkManager::writeCache()
Writes the cache of relation links.
Parameters
array $context: Context from the normalizer/serializer operation.
1 call to RelationLinkManager::writeCache()
- RelationLinkManager::getRelations in core/
modules/ rest/ src/ LinkManager/ RelationLinkManager.php - Get the array of relation links.
File
- core/
modules/ rest/ src/ LinkManager/ RelationLinkManager.php, line 125 - Contains \Drupal\rest\LinkManager\RelationLinkManager.
Class
Namespace
Drupal\rest\LinkManagerCode
protected function writeCache($context = array()) {
$data = array();
foreach ($this->entityManager
->getDefinitions() as $entity_type) {
if ($entity_type instanceof ContentEntityTypeInterface) {
foreach ($this->entityManager
->getBundleInfo($entity_type
->id()) as $bundle => $bundle_info) {
foreach ($this->entityManager
->getFieldDefinitions($entity_type
->id(), $bundle) as $field_definition) {
$relation_uri = $this
->getRelationUri($entity_type
->id(), $bundle, $field_definition
->getName(), $context);
$data[$relation_uri] = array(
'entity_type' => $entity_type,
'bundle' => $bundle,
'field_name' => $field_definition
->getName(),
);
}
}
}
}
// These URIs only change when field info changes, so cache it permanently
// and only clear it when the fields cache is cleared.
$this->cache
->set('rest:links:relations', $data, Cache::PERMANENT, array(
'entity_field_info',
));
}