You are here

trait LogCreationTrait in Log entity 2.x

Provides methods to create log entities.

This trait is meant to be used only by test classes.

Hierarchy

3 files declare their use of LogCreationTrait
LogActionsTest.php in tests/src/Kernel/LogActionsTest.php
NameAutocompleteTest.php in tests/src/Kernel/NameAutocompleteTest.php
SortTimestampIdTest.php in tests/src/Kernel/SortTimestampIdTest.php

File

tests/src/Traits/LogCreationTrait.php, line 12

Namespace

Drupal\Tests\log\Traits
View source
trait LogCreationTrait {

  /**
   * Creates a log entity.
   *
   * @param array $values
   *   Array of values to feed the entity.
   *
   * @return \Drupal\log\Entity\LogInterface
   *   The log entity.
   *
   * @throws \Drupal\Core\Entity\EntityStorageException
   */
  protected function createLogEntity(array $values = []) {

    /** @var \Drupal\log\Entity\LogInterface $entity */
    $entity = Log::create($values + [
      'name' => $this
        ->randomMachineName(),
      'type' => 'default',
    ]);
    $entity
      ->save();
    return $entity;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LogCreationTrait::createLogEntity protected function Creates a log entity.