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
- trait \Drupal\Tests\log\Traits\LogCreationTrait
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\TraitsView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LogCreationTrait:: |
protected | function | Creates a log entity. |