You are here

protected function RecentKanbanActivities::composeMessage in Content Planner 8

Composes the message.

Parameters

\Drupal\content_kanban\Entity\KanbanLog $log: The Kanban log object.

\Drupal\user\Entity\User $user: The User object.

\Drupal\Core\Entity\EntityInterface $entity: The entity object.

Return value

string Returns a string containing the composed message.

1 call to RecentKanbanActivities::composeMessage()
RecentKanbanActivities::buildKanbanLogActivities in modules/content_kanban/src/Plugin/DashboardBlock/RecentKanbanActivities.php
Builds the log entries.

File

modules/content_kanban/src/Plugin/DashboardBlock/RecentKanbanActivities.php, line 189

Class

RecentKanbanActivities
Provides a user block for Content Planner Dashboard.

Namespace

Drupal\content_kanban\Plugin\DashboardBlock

Code

protected function composeMessage(KanbanLog $log, User $user, EntityInterface $entity) {
  $state_from = $log
    ->getStateFrom();
  $state_to = $log
    ->getStateTo();
  $workflow_states = KanbanWorkflowService::getWorkflowStates($log
    ->getWorkflow());
  if ($state_from == $state_to) {
    $message = t('@username has updated @entity_type "@entity" @time ago', [
      '@username' => $user
        ->getAccountName(),
      '@entity' => $entity
        ->label(),
      '@entity_type' => ucfirst($entity
        ->getEntityTypeId()),
      '@time' => $this
        ->calculateTimeAgo($log),
    ]);
  }
  else {
    $message = t('@username has changed the state of @entity_type "@entity" from "@state_from" to "@state_to" @time ago', [
      '@username' => $user
        ->getAccountName(),
      '@entity' => $entity
        ->label(),
      '@entity_type' => ucfirst($entity
        ->getEntityTypeId()),
      '@time' => $this
        ->calculateTimeAgo($log),
      '@state_from' => $workflow_states[$state_from],
      '@state_to' => $workflow_states[$state_to],
    ]);
  }
  return $message;
}