Core and composer updates

This commit is contained in:
Rob Davies 2017-07-03 16:47:07 +01:00
parent a82634bb98
commit 62cac30480
1118 changed files with 21770 additions and 6306 deletions

View file

@ -100,17 +100,34 @@ class RelationLinkManager extends LinkManagerBase implements RelationLinkManager
* Context from the normalizer/serializer operation.
*
* @return array
* An array of typed data ids (entity_type, bundle, and field name) keyed
* by corresponding relation URI.
* An array of typed data IDs keyed by corresponding relation URI. The keys
* are:
* - 'entity_type_id'
* - 'bundle'
* - 'field_name'
* - 'entity_type' (deprecated)
* The values for 'entity_type_id', 'bundle' and 'field_name' are strings.
* The 'entity_type' key exists for backwards compatibility and its value is
* the full entity type object. The 'entity_type' key will be removed before
* Drupal 9.0.
*
* @see https://www.drupal.org/node/2877608
*/
protected function getRelations($context = []) {
$cid = 'hal:links:relations';
$cache = $this->cache->get($cid);
if (!$cache) {
$this->writeCache($context);
$cache = $this->cache->get($cid);
$data = $this->writeCache($context);
}
return $cache->data;
else {
$data = $cache->data;
}
// @todo https://www.drupal.org/node/2716163 Remove this in Drupal 9.0.
foreach ($data as $relation_uri => $ids) {
$data[$relation_uri]['entity_type'] = $this->entityManager->getDefinition($ids['entity_type_id']);
}
return $data;
}
/**
@ -118,6 +135,14 @@ class RelationLinkManager extends LinkManagerBase implements RelationLinkManager
*
* @param array $context
* Context from the normalizer/serializer operation.
*
* @return 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.
*/
protected function writeCache($context = []) {
$data = [];
@ -128,7 +153,7 @@ class RelationLinkManager extends LinkManagerBase implements RelationLinkManager
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] = [
'entity_type' => $entity_type,
'entity_type_id' => $entity_type->id(),
'bundle' => $bundle,
'field_name' => $field_definition->getName(),
];
@ -139,6 +164,7 @@ class RelationLinkManager extends LinkManagerBase implements RelationLinkManager
// 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('hal:links:relations', $data, Cache::PERMANENT, ['entity_field_info']);
return $data;
}
}

View file

@ -21,7 +21,7 @@ interface RelationLinkManagerInterface extends ConfigurableLinkManagerInterface
* (optional) Optional serializer/normalizer context.
*
* @return string
* The corresponding URI for the field.
* The corresponding URI (or IANA link relation type) for the field.
*/
public function getRelationUri($entity_type, $bundle, $field_name, $context = []);
@ -29,10 +29,12 @@ interface RelationLinkManagerInterface extends ConfigurableLinkManagerInterface
* Translates a REST URI into internal IDs.
*
* @param string $relation_uri
* Relation URI to transform into internal IDs
* Relation URI (or IANA link relation type) to transform into internal IDs.
*
* @return array
* Array with keys 'entity_type', 'bundle' and 'field_name'.
* Array with keys 'entity_type_id', 'bundle' and 'field_name'. For
* backwards compatibility, the entity_type key returns the full entity type
* object, this will be removed before Drupal 9.0.
*/
public function getRelationInternalIds($relation_uri);