Newer
Older
<?php
/**
* @file
* Admin page callbacks for the block module.
*/
Angie Byron
committed
use Drupal\block\Plugin\Core\Entity\Block;
use Drupal\Core\Template\Attribute;
Angie Byron
committed
Dries Buytaert
committed
/**
* Page callback: Attaches CSS for the block region demo.
*
* @see block_menu()
Dries Buytaert
committed
*/
function block_admin_demo($theme = NULL) {
catch
committed
return array(
'#attached' => array(
Alex Pott
committed
'css' => array(drupal_get_path('module', 'block') . '/css/block.admin.css'),
catch
committed
),
);
Dries Buytaert
committed
}
/**
Angie Byron
committed
* Page callback: Build the block instance add form.
Dries Buytaert
committed
* @param string $plugin_id
* The plugin ID for the block instance.
* @param string $theme
Angie Byron
committed
* The name of the theme for the block instance.
Dries Buytaert
committed
*
Angie Byron
committed
* @return array
* The block instance edit form.
*/
Angie Byron
committed
function block_admin_add($plugin_id, $theme) {
$entity = entity_create('block', array(
'plugin' => $plugin_id,
'theme' => $theme,
));
return Drupal::entityManager()->getForm($entity);
}
Angie Byron
committed
* Page callback: Build the block instance edit form.
Angie Byron
committed
* @param \Drupal\block\Plugin\Core\Entity\Block $entity
* The block instance.
Angie Byron
committed
* @return array
* The block instance edit form.
Angie Byron
committed
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')) {
Angie Byron
committed
$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));
}
Angie Byron
committed
Angie Byron
committed
// Get the block label for the page title.
Angie Byron
committed
drupal_set_title(t("Configure %label block in %theme", array('%label' => $entity->label(), '%theme' => $theme_title)), PASS_THROUGH);
Angie Byron
committed
return Drupal::entityManager()->getForm($entity);