You are here

public function KanbanLogService::createLogEntity in Content Planner 8

Creates a new log entry.

Parameters

string $name: The name of the entry.

int $user_id: The user id.

int $entity_id: The entity id.

string $entity_type: The entity type.

string $workflow_id: The workflow id.

null|string $state_from: The state_from value if it exists, NULL by default.

null|string $state_to: The state_to value if it exists, NULL by default.

Return value

int Returns the entity save response code for save action.

File

modules/content_kanban/src/KanbanLogService.php, line 58

Class

KanbanLogService
Class KanbanLogService.

Namespace

Drupal\content_kanban

Code

public function createLogEntity($name, $user_id, $entity_id, $entity_type, $workflow_id, $state_from = NULL, $state_to = NULL) {
  $entity_build = [
    'name' => $name,
    'user_id' => $user_id,
    'entity_id' => $entity_id,
    'entity_type' => $entity_type,
    'workflow_id' => $workflow_id,
    'state_from' => $state_from,
    'state_to' => $state_to,
  ];
  $entity = KanbanLog::create($entity_build);
  try {
    return $entity
      ->save();
  } catch (EntityStorageException $e) {
    watchdog_exception('content_kanban', $e);
  }
  return 0;
}