You are here

private function DashboardController::clearEmptyPositions in Opigno dashboard 8

Clear empty positions.

1 call to DashboardController::clearEmptyPositions()
DashboardController::getPositioning in src/Controller/DashboardController.php
Returns positioning.

File

src/Controller/DashboardController.php, line 151

Class

DashboardController
Controller for all the actions of the Learning Path manager app.

Namespace

Drupal\opigno_dashboard\Controller

Code

private function clearEmptyPositions(array &$positions, array $availables_keys) {
  foreach ($positions as $c_key => $columns) {
    if (!is_array($columns)) {
      continue;
    }
    foreach ($columns as $key => $position) {
      if (!is_array($columns)) {
        continue;
      }

      // Unset empty arrays and removed blocks.
      if (!isset($position['id']) || isset($position['id']) && !in_array($position['id'], $availables_keys)) {
        unset($positions[$c_key][$key]);
      }
    }

    // Reset array keys.
    $positions[$c_key] = array_values($positions[$c_key]);
  }
}