EntityTestUpdateStorage.php

Same filename in other branches
  1. 9 core/modules/system/tests/modules/entity_test_update/src/EntityTestUpdateStorage.php
  2. 8.9.x core/modules/system/tests/modules/entity_test_update/src/EntityTestUpdateStorage.php
  3. 10 core/modules/system/tests/modules/entity_test_update/src/EntityTestUpdateStorage.php

Namespace

Drupal\entity_test_update

File

core/modules/system/tests/modules/entity_test_update/src/EntityTestUpdateStorage.php

View source
<?php

declare (strict_types=1);
namespace Drupal\entity_test_update;

use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\Sql\SqlContentEntityStorage;

/**
 * Helper class for entity update testing.
 *
 * @see \Drupal\KernelTests\Core\Entity\FieldableEntityDefinitionUpdateTest::testFieldableEntityTypeUpdatesErrorHandling()
 */
class EntityTestUpdateStorage extends SqlContentEntityStorage {
    
    /**
     * {@inheritdoc}
     */
    protected function saveToDedicatedTables(ContentEntityInterface $entity, $update = TRUE, $names = []) {
        // Simulate an error during the 'restore' process of a test entity.
        if (\Drupal::state()->get('entity_test_update.throw_exception', FALSE)) {
            throw new \Exception('Peekaboo!');
        }
        parent::saveToDedicatedTables($entity, $update, $names);
    }

}

Classes

Title Deprecated Summary
EntityTestUpdateStorage Helper class for entity update testing.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.