diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index bcbc6bb..1ff4613 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -282,9 +282,9 @@ public function getAdminPath($entity_type, $bundle) { /** * Gets an array of entity field definitions. * - * If a 'Bundle' constraint is present, fields specific to this bundle are - * included. Entity fields are always multi-valued, so 'list' is TRUE for each - * returned field definition. + * If a bundle is passed, fields specific to this bundle are included. Entity + * fields are always multi-valued, so 'list' is TRUE for each returned field + * definition. * * @param string $entity_type * The entity type to get field definitions for. @@ -338,7 +338,7 @@ public function getFieldDefinitions($entity_type, $bundle = NULL) { foreach ($this->entityFieldInfo[$entity_type]['optional'] as &$definition) { $definition['list'] = TRUE; } - $this->cache->set($cid, $this->entityFieldInfo[$entity_type], CacheBackendInterface::CACHE_PERMANENT, array('entity_info' => TRUE)); + $this->cache->set($cid, $this->entityFieldInfo[$entity_type], CacheBackendInterface::CACHE_PERMANENT, array('entity_info' => TRUE, 'entity_field_info' => TRUE)); } } @@ -384,4 +384,13 @@ public function getFieldDefinitionsByConstraints($entity_type, array $constraint return $this->getFieldDefinitions($entity_type, isset($constraints['Bundle']) ? $constraints['Bundle'] : NULL); } + /** + * Clears static and persistent field definition caches. + */ + public function clearCachedFieldDefinitions() { + unset($this->entityFieldInfo); + unset($this->fieldDefinitions); + $this->cache->deleteTags(array('entity_field_info' => TRUE)); + } + }