summaryrefslogtreecommitdiffstats
path: root/core/modules/block/block.admin.inc
blob: 3fde289c80ae509192ab5c93d3205c748ca3d0c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php

/**
 * @file
 * Admin page callbacks for the block module.
 */

use Drupal\block\Plugin\Core\Entity\Block;
use Drupal\Core\Template\Attribute;

/**
 * Page callback: Attaches CSS for the block region demo.
 *
 * @see block_menu()
 */
function block_admin_demo($theme = NULL) {
  return array(
    '#attached' => array(
      'css' => array(drupal_get_path('module', 'block') . '/css/block.admin.css'),
    ),
  );
}

/**
 * Page callback: Build the block instance edit form.
 *
 * @param \Drupal\block\Plugin\Core\Entity\Block $entity
 *   The block instance.
 *
 * @return array
 *   The block instance edit form.
 */
function block_admin_edit(Block $entity) {
  // Get the theme for the page title.
  $admin_theme = config('system.theme')->get('admin');
  $themes = list_themes();
  $theme_key = $entity->get('theme');
  $theme = $themes[$theme_key];
  // Use meaningful titles for the main site and administrative themes.
  $theme_title = $theme->info['name'];
  if ($theme_key == config('system.theme')->get('default')) {
    $theme_title = t('!theme (default theme)', array('!theme' => $theme_title));
  }
  elseif ($admin_theme && $theme_key == $admin_theme) {
    $theme_title = t('!theme (administration theme)', array('!theme' => $theme_title));
  }

  // Get the block label for the page title.
  drupal_set_title(t("Configure %label block in %theme", array('%label' => $entity->label(), '%theme' => $theme_title)), PASS_THROUGH);

  return Drupal::entityManager()->getForm($entity);
}