protected function TypeLinkManager::writeCache in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/rest/src/LinkManager/TypeLinkManager.php \Drupal\rest\LinkManager\TypeLinkManager::writeCache()
Writes the cache of type links.
Parameters
array $context: Context from the normalizer/serializer operation.
1 call to TypeLinkManager::writeCache()
- TypeLinkManager::getTypes in core/
modules/ rest/ src/ LinkManager/ TypeLinkManager.php - Get the array of type links.
File
- core/
modules/ rest/ src/ LinkManager/ TypeLinkManager.php, line 109 - Contains \Drupal\rest\LinkManager\TypeLinkManager.
Class
Namespace
Drupal\rest\LinkManagerCode
protected function writeCache($context = array()) {
$data = array();
// Type URIs correspond to bundles. Iterate through the bundles to get the
// URI and data for them.
$entity_types = \Drupal::entityManager()
->getDefinitions();
foreach (entity_get_bundles() as $entity_type_id => $bundles) {
// Only content entities are supported currently.
// @todo Consider supporting config entities.
if ($entity_types[$entity_type_id]
->isSubclassOf('\\Drupal\\Core\\Config\\Entity\\ConfigEntityInterface')) {
continue;
}
foreach ($bundles as $bundle => $bundle_info) {
// Get a type URI for the bundle.
$bundle_uri = $this
->getTypeUri($entity_type_id, $bundle, $context);
$data[$bundle_uri] = array(
'entity_type' => $entity_type_id,
'bundle' => $bundle,
);
}
}
// These URIs only change when entity info changes, so cache it permanently
// and only clear it when entity_info is cleared.
$this->cache
->set('rest:links:types', $data, Cache::PERMANENT, array(
'entity_types',
));
}