You are here

protected function ConfigUpdateController::generateReportLinks in Configuration Update Manager 8

Generates the operations links for running individual reports.

Return value

array Render array for the operations links for running reports.

1 call to ConfigUpdateController::generateReportLinks()
ConfigUpdateController::report in config_update_ui/src/Controller/ConfigUpdateController.php
Generates the config updates report.

File

config_update_ui/src/Controller/ConfigUpdateController.php, line 215

Class

ConfigUpdateController
Returns responses for Configuration Revert module operations.

Namespace

Drupal\config_update_ui\Controller

Code

protected function generateReportLinks() {

  // These links are put into an 'operations' render array element. They do
  // not look good outside of tables. Also note that the array index in
  // operations links is used as a class on the LI element. Some classes are
  // special in the Seven CSS, such as "contextual", so avoid hitting these
  // accidentally by prefixing.
  $build = [];
  $build['links'] = [
    '#type' => 'table',
    '#header' => [
      $this
        ->t('Report type'),
      $this
        ->t('Report on'),
    ],
    '#rows' => [],
  ];

  // Full report of all configuration.
  $links['report_full'] = [
    'title' => $this
      ->t('Everything'),
    'url' => Url::fromRoute('config_update_ui.report', [
      'report_type' => 'type',
      'name' => 'system.all',
    ]),
  ];
  $build['links']['#rows'][] = [
    $this
      ->t('Full report'),
    [
      'data' => [
        '#type' => 'operations',
        '#links' => $links,
      ],
    ],
  ];

  // Reports by configuration type.
  $definitions = $this->configList
    ->listTypes();
  $links = [];
  foreach ($definitions as $entity_type => $definition) {
    $links['report_type_' . $entity_type] = [
      'title' => $definition
        ->getLabel(),
      'url' => Url::fromRoute('config_update_ui.report', [
        'report_type' => 'type',
        'name' => $entity_type,
      ]),
    ];
  }
  uasort($links, [
    $this,
    'sortLinks',
  ]);
  $links = [
    'report_type_system.simple' => [
      'title' => $this
        ->t('Simple configuration'),
      'url' => Url::fromRoute('config_update_ui.report', [
        'report_type' => 'type',
        'name' => 'system.simple',
      ]),
    ],
  ] + $links;
  $build['links']['#rows'][] = [
    $this
      ->t('Single configuration type'),
    [
      'data' => [
        '#type' => 'operations',
        '#links' => $links,
      ],
    ],
  ];

  // Make a list of installed modules.
  $profile = $this
    ->getProfileName();
  $modules = $this->moduleHandler
    ->getModuleList();
  $links = [];
  foreach ($modules as $machine_name => $module) {
    if ($machine_name != $profile && $this->configList
      ->providerHasConfig('module', $machine_name)) {
      $links['report_module_' . $machine_name] = [
        'title' => $this->moduleHandler
          ->getName($machine_name),
        'url' => Url::fromRoute('config_update_ui.report', [
          'report_type' => 'module',
          'name' => $machine_name,
        ]),
      ];
    }
  }
  uasort($links, [
    $this,
    'sortLinks',
  ]);
  $build['links']['#rows'][] = [
    $this
      ->t('Single module'),
    [
      'data' => [
        '#type' => 'operations',
        '#links' => $links,
      ],
    ],
  ];

  // Make a list of installed themes.
  $themes = $this->themeHandler
    ->listInfo();
  $links = [];
  foreach ($themes as $machine_name => $theme) {
    if ($this->configList
      ->providerHasConfig('theme', $machine_name)) {
      $links['report_theme_' . $machine_name] = [
        'title' => $this->themeHandler
          ->getName($machine_name),
        'url' => Url::fromRoute('config_update_ui.report', [
          'report_type' => 'theme',
          'name' => $machine_name,
        ]),
      ];
    }
  }
  uasort($links, [
    $this,
    'sortLinks',
  ]);
  $build['links']['#rows'][] = [
    $this
      ->t('Single theme'),
    [
      'data' => [
        '#type' => 'operations',
        '#links' => $links,
      ],
    ],
  ];
  $links = [];

  // Profile is just one option.
  if ($this->configList
    ->providerHasConfig('profile', $profile)) {
    $links['report_profile_' . $profile] = [
      'title' => $this->moduleHandler
        ->getName($profile),
      'url' => Url::fromRoute('config_update_ui.report', [
        'report_type' => 'profile',
      ]),
    ];
    $build['links']['#rows'][] = [
      $this
        ->t('Installation profile'),
      [
        'data' => [
          '#type' => 'operations',
          '#links' => $links,
        ],
      ],
    ];
  }
  return $build;
}