/** * {@inheritdoc} */ 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); } } } // 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')); }