You are here

protected function UpdateChecklist::checkAllListPoints in Update helper 2.x

Same name and namespace in other branches
  1. 8 modules/update_helper_checklist/src/UpdateChecklist.php \Drupal\update_helper_checklist\UpdateChecklist::checkAllListPoints()

Checks all the bulletpoints on a checklist.

Parameters

bool $status: Checkboxes enabled or disabled.

1 call to UpdateChecklist::checkAllListPoints()
UpdateChecklist::markAllUpdates in modules/update_helper_checklist/src/UpdateChecklist.php
Marks a list of updates.

File

modules/update_helper_checklist/src/UpdateChecklist.php, line 223

Class

UpdateChecklist
Update checklist service.

Namespace

Drupal\update_helper_checklist

Code

protected function checkAllListPoints($status = TRUE) {
  $current_progress = $this->checkListStateStorage
    ->setChecklistId('update_helper_checklist')
    ->getSavedProgress();
  $user = $this->account
    ->id();
  $time = time();
  $current_progress['#changed'] = $time;
  $current_progress['#changed_by'] = $user;
  $exclude = [
    '#title',
    '#description',
    '#weight',
  ];
  foreach ($this
    ->getChecklist()->items as $version_items) {
    foreach ($version_items as $item_name => $item) {
      if (!in_array($item_name, $exclude)) {
        if ($status) {
          $current_progress['#items'][$item_name] = [
            '#completed' => $time,
            '#uid' => $user,
          ];
        }
        else {
          unset($current_progress['#items'][$item_name]);
        }
      }
    }
  }
  $current_progress['#completed_items'] = empty($current_progress['#items']) ? 0 : count($current_progress['#items']);
  $this->checkListStateStorage
    ->setChecklistId('update_helper_checklist')
    ->setSavedProgress($current_progress);
}