class EntityTestBundleClass

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/modules/entity_test_bundle_class/src/Entity/EntityTestBundleClass.php \Drupal\entity_test_bundle_class\Entity\EntityTestBundleClass

The bundle class for the bundle_class bundle of the entity_test entity.

Hierarchy

Expanded class hierarchy of EntityTestBundleClass

2 files declare their use of EntityTestBundleClass
BundleClassTest.php in core/tests/Drupal/KernelTests/Core/Entity/BundleClassTest.php
entity_test_bundle_class.module in core/modules/system/tests/modules/entity_test_bundle_class/entity_test_bundle_class.module
Support module for testing entity bundle classes.

File

core/modules/system/tests/modules/entity_test_bundle_class/src/Entity/EntityTestBundleClass.php, line 11

Namespace

Drupal\entity_test_bundle_class\Entity
View source
class EntityTestBundleClass extends EntityTest {
  
  /**
   * The number of times static::preCreate() was called.
   *
   * @var int
   */
  public static $preCreateCount = 0;
  
  /**
   * The number of times static::postCreate() was called.
   *
   * This does not need to be static, since postCreate() is not static.
   *
   * @var int
   */
  public $postCreateCount = 0;
  
  /**
   * The number of times static::preDelete() was called.
   *
   * @var int
   */
  public static $preDeleteCount = 0;
  
  /**
   * The number of times static::postDelete() was called.
   *
   * @var int
   */
  public static $postDeleteCount = 0;
  
  /**
   * The number of times static::postLoad() was called.
   *
   * @var int
   */
  public static $postLoadCount = 0;
  
  /**
   * The size of the $entities array passed to each invocation of postLoad().
   *
   * @var int[]
   */
  public static $postLoadEntitiesCount = [];
  
  /**
   * {@inheritdoc}
   */
  public static function preCreate(EntityStorageInterface $storage, array &$values) {
    parent::preCreate($storage, $values);
    self::$preCreateCount++;
  }
  
  /**
   * {@inheritdoc}
   */
  public function postCreate(EntityStorageInterface $storage) {
    parent::postCreate($storage);
    $this->postCreateCount++;
  }
  
  /**
   * {@inheritdoc}
   */
  public static function preDelete(EntityStorageInterface $storage, array $entities) {
    parent::preDelete($storage, $entities);
    self::$preDeleteCount++;
  }
  
  /**
   * {@inheritdoc}
   */
  public static function postDelete(EntityStorageInterface $storage, array $entities) {
    parent::postDelete($storage, $entities);
    self::$postDeleteCount++;
  }
  
  /**
   * {@inheritdoc}
   */
  public static function postLoad(EntityStorageInterface $storage, array &$entities) {
    parent::postLoad($storage, $entities);
    self::$postLoadCount++;
    self::$postLoadEntitiesCount[] = count($entities);
  }

}

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