Commit d6cda570 authored by webchick's avatar webchick

Issue #2113319 by Xano: Rename getOriginalID() to getOriginalId() and...

Issue #2113319 by Xano: Rename getOriginalID() to getOriginalId() and setOriginalID() to setOriginalId().
parent 7e85262f
......@@ -393,8 +393,8 @@ public function save(EntityInterface $entity) {
// Load the stored entity, if any.
// At this point, the original ID can only be NULL or a valid ID.
if ($entity->getOriginalID() !== NULL) {
$id = $entity->getOriginalID();
if ($entity->getOriginalId() !== NULL) {
$id = $entity->getOriginalId();
}
$config = $this->configFactory->get($prefix . $id);
$is_new = $config->isNew();
......@@ -432,7 +432,7 @@ public function save(EntityInterface $entity) {
$this->invokeHook('update', $entity);
// Immediately update the original ID.
$entity->setOriginalID($entity->id());
$entity->setOriginalId($entity->id());
}
else {
$return = SAVED_NEW;
......
......@@ -813,11 +813,11 @@ function book_type_is_allowed($type) {
* node type is changed.
*/
function book_node_type_update(NodeTypeInterface $type) {
if ($type->getOriginalID() != $type->id()) {
if ($type->getOriginalId() != $type->id()) {
$config = \Drupal::config('book.settings');
// Update the list of node types that are allowed to be added to books.
$allowed_types = $config->get('allowed_types');
$old_key = array_search($type->getOriginalID(), $allowed_types);
$old_key = array_search($type->getOriginalId(), $allowed_types);
if ($old_key !== FALSE) {
$allowed_types[$old_key] = $type->id();
......@@ -828,7 +828,7 @@ function book_node_type_update(NodeTypeInterface $type) {
}
// Update the setting for the "Add child page" link.
if ($config->get('child_type') == $type->getOriginalID()) {
if ($config->get('child_type') == $type->getOriginalId()) {
$config->set('child_type', $type->id());
}
$config->save();
......
......@@ -46,7 +46,7 @@ function testCRUD() {
// Verify ConfigEntity properties/methods on the newly created empty entity.
$this->assertIdentical($empty->isNew(), TRUE);
$this->assertIdentical($empty->getOriginalID(), NULL);
$this->assertIdentical($empty->getOriginalId(), NULL);
$this->assertIdentical($empty->bundle(), 'config_test');
$this->assertIdentical($empty->id(), NULL);
$this->assertTrue($empty->uuid());
......@@ -100,7 +100,7 @@ function testCRUD() {
// Verify methods on the newly created entity.
$this->assertIdentical($config_test->isNew(), TRUE);
$this->assertIdentical($config_test->getOriginalID(), $expected['id']);
$this->assertIdentical($config_test->getOriginalId(), $expected['id']);
$this->assertIdentical($config_test->id(), $expected['id']);
$this->assertTrue($config_test->uuid());
$expected['uuid'] = $config_test->uuid();
......@@ -124,7 +124,7 @@ function testCRUD() {
$this->assertIdentical($config_test->uuid(), $expected['uuid']);
$this->assertIdentical($config_test->label(), $expected['label']);
$this->assertIdentical($config_test->isNew(), FALSE);
$this->assertIdentical($config_test->getOriginalID(), $expected['id']);
$this->assertIdentical($config_test->getOriginalId(), $expected['id']);
// Save again, and verify correct status and properties again.
$status = $config_test->save();
......@@ -133,7 +133,7 @@ function testCRUD() {
$this->assertIdentical($config_test->uuid(), $expected['uuid']);
$this->assertIdentical($config_test->label(), $expected['label']);
$this->assertIdentical($config_test->isNew(), FALSE);
$this->assertIdentical($config_test->getOriginalID(), $expected['id']);
$this->assertIdentical($config_test->getOriginalId(), $expected['id']);
// Re-create the entity with the same ID and verify updated status.
$same_id = entity_create('config_test', array(
......@@ -161,7 +161,7 @@ function testCRUD() {
$new_id = $ids[$i];
// Before renaming, everything should point to the current ID.
$this->assertIdentical($config_test->id(), $old_id);
$this->assertIdentical($config_test->getOriginalID(), $old_id);
$this->assertIdentical($config_test->getOriginalId(), $old_id);
// Rename.
$config_test->id = $new_id;
......@@ -172,7 +172,7 @@ function testCRUD() {
// Verify that originalID points to new ID directly after renaming.
$this->assertIdentical($config_test->id(), $new_id);
$this->assertIdentical($config_test->getOriginalID(), $new_id);
$this->assertIdentical($config_test->getOriginalId(), $new_id);
}
// Test config entity prepopulation.
......
......@@ -387,7 +387,7 @@ protected function saveNew() {
protected function saveUpdated() {
$instance_controller = \Drupal::entityManager()->getStorageController($this->entityType);
$original = $instance_controller->loadUnchanged($this->getOriginalID());
$original = $instance_controller->loadUnchanged($this->getOriginalId());
$this->original = $original;
// Some updates are always disallowed.
......
......@@ -144,7 +144,7 @@ public static function postDelete(EntityStorageControllerInterface $storage_cont
* The image style.
*/
protected static function replaceImageStyle(ImageStyleInterface $style) {
if ($style->id() != $style->getOriginalID()) {
if ($style->id() != $style->getOriginalId()) {
// Loop through all fields searching for image fields.
foreach (field_read_instances() as $instance) {
if ($instance->getFieldType() == 'image') {
......@@ -155,7 +155,7 @@ protected static function replaceImageStyle(ImageStyleInterface $style) {
$display_options = $display->getComponent($field_name);
// Check if the formatter involves an image style.
if ($display_options && $display_options['type'] == 'image' && $display_options['settings']['image_style'] == $style->getOriginalID()) {
if ($display_options && $display_options['type'] == 'image' && $display_options['settings']['image_style'] == $style->getOriginalId()) {
// Update display information for any instance using the image
// style that was just deleted.
$display_options['settings']['image_style'] = $style->id();
......@@ -165,7 +165,7 @@ protected static function replaceImageStyle(ImageStyleInterface $style) {
}
$entity_form_display = entity_get_form_display($instance->entity_type, $instance->bundle, 'default');
$widget_configuration = $entity_form_display->getComponent($field_name);
if ($widget_configuration['settings']['preview_image_style'] == $style->getOriginalID()) {
if ($widget_configuration['settings']['preview_image_style'] == $style->getOriginalId()) {
$widget_options['settings']['preview_image_style'] = $style->id();
$entity_form_display->setComponent($field_name, $widget_options)
->save();
......
......@@ -176,21 +176,21 @@ public function postSave(EntityStorageControllerInterface $storage_controller, $
node_add_body_field($this, $label);
}
}
elseif ($this->getOriginalID() != $this->id()) {
elseif ($this->getOriginalId() != $this->id()) {
// Clear the node type cache to reflect the rename.
\Drupal::cache()->deleteTags(array('node_types' => TRUE));
$update_count = node_type_update_nodes($this->getOriginalID(), $this->id());
$update_count = node_type_update_nodes($this->getOriginalId(), $this->id());
if ($update_count) {
drupal_set_message(format_plural($update_count,
'Changed the content type of 1 post from %old-type to %type.',
'Changed the content type of @count posts from %old-type to %type.',
array(
'%old-type' => $this->getOriginalID(),
'%old-type' => $this->getOriginalId(),
'%type' => $this->id(),
)));
}
entity_invoke_bundle_hook('rename', 'node', $this->getOriginalID(), $this->id());
entity_invoke_bundle_hook('rename', 'node', $this->getOriginalId(), $this->id());
}
else {
// Invalidate the cache tag of the updated node type only.
......
......@@ -213,7 +213,7 @@ public function save(array $form, array &$form_state) {
// Save or reset persistent variable values.
foreach ($variables as $key => $value) {
$variable_new = $key . '_' . $type->id();
$variable_old = $key . '_' . $type->getOriginalID();
$variable_old = $key . '_' . $type->getOriginalId();
if (is_array($value)) {
$value = array_keys(array_filter($value));
}
......
......@@ -79,7 +79,7 @@ public function postCreate(EntityStorageControllerInterface $storage_controller)
parent::postCreate($storage_controller);
// Generate menu-compatible set name.
if (!$this->getOriginalID()) {
if (!$this->getOriginalId()) {
// Save a new shortcut set with links copied from the user's default set.
$default_set = shortcut_default_set();
// Generate a name to have no collisions with menu.
......
......@@ -74,7 +74,7 @@ public function validate(array $form, array &$form_state) {
*/
public function save(array $form, array &$form_state) {
$entity = $this->entity;
$is_new = !$entity->getOriginalID();
$is_new = !$entity->getOriginalId();
$entity->save();
if ($is_new) {
......
......@@ -107,7 +107,7 @@ public function postSave(EntityStorageControllerInterface $storage_controller, $
if (!$update) {
entity_invoke_bundle_hook('create', 'taxonomy_term', $this->id());
}
elseif ($this->getOriginalID() != $this->id()) {
elseif ($this->getOriginalId() != $this->id()) {
// Reflect machine name changes in the definitions of existing 'taxonomy'
// fields.
$fields = field_read_fields();
......@@ -115,7 +115,7 @@ public function postSave(EntityStorageControllerInterface $storage_controller, $
$update_field = FALSE;
if ($field->getFieldType() == 'taxonomy_term_reference') {
foreach ($field->settings['allowed_values'] as &$value) {
if ($value['vocabulary'] == $this->getOriginalID()) {
if ($value['vocabulary'] == $this->getOriginalId()) {
$value['vocabulary'] = $this->id();
$update_field = TRUE;
}
......@@ -126,9 +126,9 @@ public function postSave(EntityStorageControllerInterface $storage_controller, $
}
}
// Update bundles.
entity_invoke_bundle_hook('rename', 'taxonomy_term', $this->getOriginalID(), $this->id());
entity_invoke_bundle_hook('rename', 'taxonomy_term', $this->getOriginalId(), $this->id());
}
$storage_controller->resetCache($update ? array($this->getOriginalID()) : array());
$storage_controller->resetCache($update ? array($this->getOriginalId()) : array());
}
/**
......
......@@ -33,7 +33,7 @@ public static function getInfo() {
*/
public function testEntityDecoration() {
$method_args = array();
$method_args['setOriginalID'] = array(12);
$method_args['setOriginalId'] = array(12);
$method_args['setStatus'] = array(TRUE);
$method_args['enforceIsNew'] = array(FALSE);
$method_args['label'] = array(Language::LANGCODE_NOT_SPECIFIED);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment