diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php index 330f39c..a5000ce 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -110,4 +110,20 @@ public static function sort($a, $b) { } return ($a_weight < $b_weight) ? -1 : 1; } + + /** + * Overrides \Drupal\Core\Entity\Entity::getExportProperties(). + */ + public function getExportProperties() { + // Configuration objects do not have a schema. Extract all key names from + // class properties. + $class_info = new \ReflectionClass($this); + $properties = array(); + foreach ($class_info->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { + $name = $property->getName(); + $properties[$name] = $this->get($name); + } + return $properties; + } + } diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php index 6d0a3f4..fbd6611 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php @@ -299,7 +299,7 @@ public function save(EntityInterface $entity) { $this->invokeHook('presave', $entity); // Retrieve the desired properties and set them in config. - foreach ($this->getProperties($entity) as $key => $value) { + foreach ($entity->getExportProperties() as $key => $value) { $config->set($key, $value); } @@ -336,29 +336,6 @@ public function save(EntityInterface $entity) { } /** - * Retrieves the exportable properties of an entity. - * - * @param \Drupal\Core\Entity\EntityInterface $entity - * The entity being saved. - * - * @return array - * An array of exportable properties and their values. - * - * @see \Drupal\Core\Config\Entity\ConfigStorageController::save() - */ - protected function getProperties(EntityInterface $entity) { - // Configuration objects do not have a schema. Extract all key names from - // class properties. - $class_info = new \ReflectionClass($entity); - $properties = array(); - foreach ($class_info->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { - $name = $property->getName(); - $properties[$name] = $entity->$name; - } - return $properties; - } - - /** * Acts on an entity before the presave hook is invoked. * * Used before the entity is saved and before invoking the presave hook. diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index 979614f..1b511e1 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -371,4 +371,12 @@ public function isDefaultRevision($new_value = NULL) { } return $return; } + + /** + * Implements Drupal\Core\Entity\EntityInterface::getExportProperties(). + */ + public function getExportProperties() { + return array(); + } + } diff --git a/core/lib/Drupal/Core/Entity/EntityInterface.php b/core/lib/Drupal/Core/Entity/EntityInterface.php index 9b751d4..a3e4a62 100644 --- a/core/lib/Drupal/Core/Entity/EntityInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityInterface.php @@ -181,4 +181,13 @@ public function getRevisionId(); * $new_value was passed, the previous value is returned. */ public function isDefaultRevision($new_value = NULL); + + /** + * Retrieves the exportable properties of the entity. + * + * @return array + * An array of exportable properties and their values. + */ + public function getExportProperties(); + } diff --git a/core/modules/views/lib/Drupal/views/Plugin/Core/Entity/View.php b/core/modules/views/lib/Drupal/views/Plugin/Core/Entity/View.php index f31dcae..ad518b8 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Core/Entity/View.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Core/Entity/View.php @@ -371,4 +371,29 @@ public function getPaths() { return array_unique($all_paths); } + /** + * Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::getExportProperties(); + */ + public function getExportProperties() { + $names = array( + 'api_version', + 'base_field', + 'base_table', + 'core', + 'description', + 'disabled', + 'display', + 'human_name', + 'module', + 'name', + 'tag', + 'uuid', + ); + $properties = array(); + foreach ($names as $name) { + $properties[$name] = $this->get($name); + } + return $properties; + } + } diff --git a/core/modules/views/lib/Drupal/views/ViewStorageController.php b/core/modules/views/lib/Drupal/views/ViewStorageController.php index 05268d2..a3a3437 100644 --- a/core/modules/views/lib/Drupal/views/ViewStorageController.php +++ b/core/modules/views/lib/Drupal/views/ViewStorageController.php @@ -99,29 +99,4 @@ protected function attachDisplays(EntityInterface $entity) { } } - /** - * Overrides Drupal\config\ConfigStorageController::getProperties(); - */ - protected function getProperties(EntityInterface $entity) { - $names = array( - 'api_version', - 'base_field', - 'base_table', - 'core', - 'description', - 'disabled', - 'display', - 'human_name', - 'module', - 'name', - 'tag', - 'uuid', - ); - $properties = array(); - foreach ($names as $name) { - $properties[$name] = $entity->get($name); - } - return $properties; - } - } diff --git a/core/modules/views/views_ui/lib/Drupal/views_ui/ViewUI.php b/core/modules/views/views_ui/lib/Drupal/views_ui/ViewUI.php index fa8fc58..a6503ec 100644 --- a/core/modules/views/views_ui/lib/Drupal/views_ui/ViewUI.php +++ b/core/modules/views/views_ui/lib/Drupal/views_ui/ViewUI.php @@ -969,6 +969,13 @@ public function enforceIsNew($value = TRUE) { } /** + * Implements \Drupal\Core\Entity\EntityInterface::getExportProperties(). + */ + public function getExportProperties() { + return $this->__call(__FUNCTION__, func_get_args()); + } + + /** * Implements \Drupal\Core\TypedData\TranslatableInterface::getTranslation(). */ public function getTranslation($langcode, $strict = TRUE) {