You are here

public function LogStorage::generate in Commerce Core 8.2

Generates a log.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $source: The source entity.

string $template_id: The template ID.

array $params: An array of params for the log.

Return value

\Drupal\commerce_log\Entity\LogInterface The generated log, unsaved.

Overrides LogStorageInterface::generate

File

modules/log/src/LogStorage.php, line 78

Class

LogStorage

Namespace

Drupal\commerce_log

Code

public function generate(ContentEntityInterface $source, $template_id, array $params = []) {
  $template_plugin = $this->logTemplateManager
    ->getDefinition($template_id);
  $log = $this
    ->create([
    'category_id' => $template_plugin['category'],
    'template_id' => $template_id,
    'source_entity_id' => $source
      ->id(),
    'source_entity_type' => $source
      ->getEntityTypeId(),
    'params' => $params,
  ]);
  return $log;
}