class Progress

Same name in this branch
  1. 8.x-1.x src/Plugin/views/field/Progress.php \Drupal\tmgmt\Plugin\views\field\Progress
  2. 8.x-1.x translators/tmgmt_local/src/Plugin/views/field/Progress.php \Drupal\tmgmt_local\Plugin\views\field\Progress

Field handler which shows the progress of a job or job item.

Plugin annotation

@ViewsField("tmgmt_local_progress");

Hierarchy

  • class \Drupal\tmgmt\Plugin\views\field\StatisticsBase extends \Drupal\views\Plugin\views\field\FieldPluginBase
    • class \Drupal\tmgmt_local\Plugin\views\field\Progress

Expanded class hierarchy of Progress

11 string references to 'Progress'
JobItemViewsData::getViewsData in src/Entity/ViewsData/JobItemViewsData.php
JobViewsData::getViewsData in src/Entity/ViewsData/JobViewsData.php
LocalTaskItemViewsData::getViewsData in translators/tmgmt_local/src/Entity/ViewsData/LocalTaskItemViewsData.php
LocalTaskViewsData::getViewsData in translators/tmgmt_local/src/Entity/ViewsData/LocalTaskViewsData.php
tmgmt_local.views.schema.yml in translators/tmgmt_local/config/schema/tmgmt_local.views.schema.yml
translators/tmgmt_local/config/schema/tmgmt_local.views.schema.yml

... See full list

File

translators/tmgmt_local/src/Plugin/views/field/Progress.php, line 15

Namespace

Drupal\tmgmt_local\Plugin\views\field
View source
class Progress extends StatisticsBase {

  /**
   * {@inheritdoc}
   */
  public function render(ResultRow $values) {
    $entity = $values->_entity;
    if ($entity
      ->getEntityTypeId() == 'tmgmt_local_task' && $entity
      ->getStatus() == LocalTaskInterface::STATUS_CLOSED || $entity
      ->getEntityTypeId() == 'tmgmt_local_task_item' && $entity
      ->getStatus() == LocalTaskItemInterface::STATUS_CLOSED) {
      return t('Closed');
    }
    $counts = array(
      '@untranslated' => $entity
        ->getCountUntranslated(),
      '@translated' => $entity
        ->getCountTranslated(),
      '@completed' => $entity
        ->getCountCompleted(),
    );
    $title = t('Untranslated: @untranslated, translated: @translated, completed: @completed.', $counts);
    $one_hundred_percent = array_sum($counts);
    if ($one_hundred_percent == 0) {
      return [];
    }
    $output = array(
      '#theme' => 'tmgmt_local_progress_bar',
      '#attached' => array(
        'library' => 'tmgmt/admin',
      ),
      '#title' => $title,
      '#count_untranslated' => $counts['@untranslated'],
      '#count_translated' => $counts['@translated'],
      '#count_completed' => $counts['@completed'],
      '#width_untranslated' => $counts['@untranslated'] / $one_hundred_percent * 100,
      '#width_translated' => $counts['@translated'] / $one_hundred_percent * 100,
      '#width_completed' => $counts['@completed'] / $one_hundred_percent * 100,
    );
    return $output;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Progress::render public function
StatisticsBase::preRender public function Prefetch statistics for all jobs.