public function AutoBlockSchedulerController::scheduler_block_list in Auto Block Scheduler 8
1 string reference to 'AutoBlockSchedulerController::scheduler_block_list'
File
- src/
Controller/ AutoBlockSchedulerController.php, line 12
Class
Namespace
Drupal\auto_block_scheduler\ControllerCode
public function scheduler_block_list() {
$blocks = Block::loadMultiple();
$current_url = Url::fromRoute('<current>');
$destination = $current_url
->toString();
$rows = [];
$inc = 0;
foreach ($blocks as $key => $block) {
$settings = $block
->get('visibility');
$url = Url::fromRoute('entity.block.edit_form', [
'block' => $key,
], [
'query' => [
'destination' => $destination,
],
'absolute' => TRUE,
]);
if (isset($settings['auto_block_scheduler'])) {
$rows[$inc]['id'] = $key;
$rows[$inc]['label'] = $block
->get('settings')['label'];
$rows[$inc]['published_on'] = !empty($settings['auto_block_scheduler']['published_on']) ? DrupalDateTime::createFromTimestamp($settings['auto_block_scheduler']['published_on']) : 'NA';
$rows[$inc]['unpublished_on'] = !empty($settings['auto_block_scheduler']['unpublished_on']) ? DrupalDateTime::createFromTimestamp($settings['auto_block_scheduler']['unpublished_on']) : 'NA';
$rows[$inc]['negate'] = !empty($settings['auto_block_scheduler']['negate']) ? '1' : '0';
$rows[$inc]['configure'] = \Drupal::l('Configure', $url);
$inc++;
}
}
return [
'#type' => 'table',
'#header' => [
'id' => 'Id',
'label' => 'Label',
'published_on' => 'Published On',
'unpublished_on' => 'Unpublished On',
'negate' => 'Negate',
'operation' => 'Operation',
],
'#rows' => $rows,
"#sticky" => true,
"#empty" => "No, Block scheduled with auto block scheduler",
'#caption' => $this
->t("Auto Block Scheduler"),
];
}