Commit 5cbaf8cc authored by webchick's avatar webchick

Issue #2452499 by arpitr: Remove deprecated function definition for...

Issue #2452499 by arpitr: Remove deprecated function definition for entity_load_by_uuid() and its references
parent c9b25308
......@@ -105,30 +105,6 @@ function entity_revision_delete($entity_type, $revision_id) {
->deleteRevision($revision_id);
}
/**
* Loads an entity by UUID.
*
* Note that some entity types may not support UUIDs.
*
* @param string $entity_type_id
* The entity type to load; e.g., 'node' or 'user'.
* @param string $uuid
* The UUID of the entity to load.
*
* @return EntityInterface|FALSE
* The entity object, or FALSE if there is no entity with the given UUID.
*
* @throws \Drupal\Core\Entity\EntityStorageException
* Thrown in case the requested entity type does not support UUIDs.
*
* @see \Drupal\Core\Entity\EntityManagerInterface
*
* @deprecated Use \Drupal::entityManager()->loadEntityByUuid();
*/
function entity_load_by_uuid($entity_type_id, $uuid) {
return \Drupal::entityManager()->loadEntityByUuid($entity_type_id, $uuid);
}
/**
* Loads multiple entities from the database.
*
......
......@@ -70,7 +70,7 @@ public function testStorageMethods() {
$entity->save();
// Ensure that the configuration entity can be loaded by UUID.
$entity_loaded_by_uuid = entity_load_by_uuid($entity_type->id(), $entity->uuid());
$entity_loaded_by_uuid = \Drupal::entityManager()->loadEntityByUuid($entity_type->id(), $entity->uuid());
if (!$entity_loaded_by_uuid) {
$this->fail(sprintf("Failed to load '%s' entity ID '%s' by UUID '%s'.", $entity_type->id(), $entity->id(), $entity->uuid()));
}
......
......@@ -411,7 +411,7 @@ function editor_entity_revision_delete(EntityInterface $entity) {
*/
function _editor_record_file_usage(array $uuids, EntityInterface $entity) {
foreach ($uuids as $uuid) {
if ($file = entity_load_by_uuid('file', $uuid)) {
if ($file = \Drupal::entityManager()->loadEntityByUuid('file', $uuid)) {
if ($file->status !== FILE_STATUS_PERMANENT) {
$file->status = FILE_STATUS_PERMANENT;
$file->save();
......@@ -436,7 +436,7 @@ function _editor_record_file_usage(array $uuids, EntityInterface $entity) {
*/
function _editor_delete_file_usage(array $uuids, EntityInterface $entity, $count) {
foreach ($uuids as $uuid) {
if ($file = entity_load_by_uuid('file', $uuid)) {
if ($file = \Drupal::entityManager()->loadEntityByUuid('file', $uuid)) {
\Drupal::service('file.usage')->delete($file, 'editor', $entity->getEntityTypeId(), $entity->id(), $count);
}
}
......
......@@ -60,7 +60,7 @@ public function buildForm(array $form, FormStateInterface $form_state, FilterFor
}
$max_filesize = min(Bytes::toInt($image_upload['max_size']), file_upload_max_size());
$existing_file = isset($image_element['data-entity-uuid']) ? entity_load_by_uuid('file', $image_element['data-entity-uuid']) : NULL;
$existing_file = isset($image_element['data-entity-uuid']) ? \Drupal::entityManager()->loadEntityByUuid('file', $image_element['data-entity-uuid']) : NULL;
$fid = $existing_file ? $existing_file->id() : NULL;
$form['fid'] = array(
......
......@@ -101,7 +101,7 @@ public function testImportDeleteUninstall() {
$this->configImporter()->import();
$this->assertFalse(\Drupal::moduleHandler()->moduleExists('telephone'));
$this->assertFalse(entity_load_by_uuid('field_storage_config', $field_storage->uuid()), 'The test field has been deleted by the configuration synchronization');
$this->assertFalse(\Drupal::entityManager()->loadEntityByUuid('field_storage_config', $field_storage->uuid()), 'The test field has been deleted by the configuration synchronization');
$deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: array();
$this->assertFalse(isset($deleted_storages[$field_storage->uuid()]), 'Telephone field has been completed removed from the system.');
$this->assertTrue(isset($deleted_storages[$unrelated_field_storage->uuid()]), 'Unrelated field not purged by configuration synchronization.');
......
......@@ -119,7 +119,7 @@ public function testImportDeleteUninstall() {
$this->assertNoText('Field data will be deleted by this synchronization.');
$this->rebuildContainer();
$this->assertFalse(\Drupal::moduleHandler()->moduleExists('telephone'));
$this->assertFalse(entity_load_by_uuid('field_storage_config', $field_storage->uuid()), 'The telephone field has been deleted by the configuration synchronization');
$this->assertFalse(\Drupal::entityManager()->loadEntityByUuid('field_storage_config', $field_storage->uuid()), 'The telephone field has been deleted by the configuration synchronization');
$deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: array();
$this->assertFalse(isset($deleted_storages[$field_storage->uuid()]), 'Telephone field has been completed removed from the system.');
$this->assertFalse(isset($deleted_storages[$field_storage->uuid()]), 'Text field has been completed removed from the system.');
......
......@@ -92,9 +92,9 @@ public function testUuidValues() {
$file->save();
file_test_reset();
$by_uuid_file = entity_load_by_uuid('file', $file->uuid());
$by_uuid_file = \Drupal::entityManager()->loadEntityByUuid('file', $file->uuid());
$this->assertFileHookCalled('load');
$this->assertTrue(is_object($by_uuid_file), 'entity_load_by_uuid() returned a file object.');
$this->assertTrue(is_object($by_uuid_file), '\Drupal::entityManager()->loadEntityByUuid() returned a file object.');
if (is_object($by_uuid_file)) {
$this->assertEqual($by_uuid_file->id(), $file->id(), 'Loading by UUID got the same fid.', 'File');
$this->assertTrue($by_uuid_file->file_test['loaded'], 'file_test_file_load() was able to modify the file during load.');
......
......@@ -69,8 +69,8 @@ protected function assertCRUD($entity_type) {
$entity_loaded = entity_load($entity_type, $entity->id(), TRUE);
$this->assertIdentical($entity_loaded->uuid(), $uuid);
// Verify that entity_load_by_uuid() loads the same entity.
$entity_loaded_by_uuid = entity_load_by_uuid($entity_type, $uuid, TRUE);
// Verify that \Drupal::entityManager()->loadEntityByUuid() loads the same entity.
$entity_loaded_by_uuid = \Drupal::entityManager()->loadEntityByUuid($entity_type, $uuid, TRUE);
$this->assertIdentical($entity_loaded_by_uuid->uuid(), $uuid);
$this->assertEqual($entity_loaded_by_uuid->id(), $entity_loaded->id());
......
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