protected function RelationLinkManager::writeCache

Writes the cache of relation links.

1 call to RelationLinkManager::writeCache()
RelationLinkManager::getRelations in drupal/core/modules/rest/lib/Drupal/rest/LinkManager/RelationLinkManager.php
Get the array of relation links.

File

drupal/core/modules/rest/lib/Drupal/rest/LinkManager/RelationLinkManager.php, line 74
Contains \Drupal\rest\LinkManager\RelationLinkManager.

Class

RelationLinkManager

Namespace

Drupal\rest\LinkManager

Code

protected function writeCache() {
  $data = array();
  foreach (field_info_fields() as $field_info) {
    foreach ($field_info['bundles'] as $entity_type => $bundles) {
      foreach ($bundles as $bundle) {
        $relation_uri = $this
          ->getRelationUri($entity_type, $bundle, $field_info['field_name']);
        $data[$relation_uri] = array(
          'entity_type' => $entity_type,
          'bundle' => $bundle,
          'field_name' => $field_info['field_name'],
        );
      }
    }
  }

  // These URIs only change when field info changes, so cache it permanently
  // and only clear it when field_info is cleared.
  $this->cache
    ->set('rest:links:relations', $data, CacheBackendInterface::CACHE_PERMANENT, array(
    'field_info' => TRUE,
  ));
}