diff --git a/core/modules/block/lib/Drupal/block/BlockFormController.php b/core/modules/block/lib/Drupal/block/BlockFormController.php
index 3419afc..2d74a70 100644
--- a/core/modules/block/lib/Drupal/block/BlockFormController.php
+++ b/core/modules/block/lib/Drupal/block/BlockFormController.php
@@ -93,6 +93,16 @@ public static function create(ContainerInterface $container) {
*/
public function form(array $form, array &$form_state) {
$entity = $this->entity;
+
+ // Store theme settings in $form_state and use them in the theme settings below.
+ if ($entity->get('theme')) {
+ $theme = $entity->get('theme');
+ }
+ else {
+ $theme = $this->configFactory->get('system.theme')->get('default');
+ }
+ $form_state['block_theme'] = $theme;
+
$form['#tree'] = TRUE;
$form['settings'] = $entity->getPlugin()->buildConfigurationForm(array(), $form_state);
@@ -232,7 +242,7 @@ public function form(array $form, array &$form_state) {
if ($theme = $entity->get('theme')) {
$form['theme'] = array(
'#type' => 'value',
- '#value' => $entity->get('theme'),
+ '#value' => $theme,
);
}
else {
@@ -242,7 +252,6 @@ public function form(array $form, array &$form_state) {
$theme_options[$theme_name] = $theme_info->info['name'];
}
}
- $theme = $this->configFactory->get('system.theme')->get('default');
$form['theme'] = array(
'#type' => 'select',
'#options' => $theme_options,
@@ -254,6 +263,8 @@ public function form(array $form, array &$form_state) {
),
);
}
+ $form_state['block_theme'] = $theme;
+
// Region settings.
$form['region'] = array(
'#type' => 'select',
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockSystemBrandingTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockSystemBrandingTest.php
index 4d8ca07..38f78b9 100644
--- a/core/modules/block/lib/Drupal/block/Tests/BlockSystemBrandingTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockSystemBrandingTest.php
@@ -42,7 +42,7 @@ function setUp() {
*/
function testSystemBrandingSettings() {
$site_logo_xpath = '//div[@id="block-site-branding"]//a[@class="site-logo"]';
- $site_name_xpath = '//div[@id="block-site-branding"]//strong[@class="site-name"]';
+ $site_name_xpath = '//div[@id="block-site-branding"]//div[@class="site-name"]';
$site_slogan_xpath = '//div[@id="block-site-branding"]//div[@class="site-slogan"]';
// Set default block settings.
diff --git a/core/modules/system/lib/Drupal/system/Plugin/Block/SystemBrandingBlock.php b/core/modules/system/lib/Drupal/system/Plugin/Block/SystemBrandingBlock.php
index bcbf028..9753ab0 100644
--- a/core/modules/system/lib/Drupal/system/Plugin/Block/SystemBrandingBlock.php
+++ b/core/modules/system/lib/Drupal/system/Plugin/Block/SystemBrandingBlock.php
@@ -10,8 +10,10 @@
use Drupal\block\BlockBase;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
+use Drupal\Core\Routing\UrlGeneratorInterface;
use Drupal\Component\Utility\Xss;
use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\HttpFoundation\Request;
/**
* Provides a block to display 'Site branding' elements.
@@ -24,6 +26,13 @@
class SystemBrandingBlock extends BlockBase implements ContainerFactoryPluginInterface {
/**
+ * The URL generator.
+ *
+ * @var \Drupal\Core\Routing\UrlGeneratorInterface
+ */
+ protected $urlGenerator;
+
+ /**
* Stores the configuration factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
@@ -31,6 +40,13 @@ class SystemBrandingBlock extends BlockBase implements ContainerFactoryPluginInt
protected $configFactory;
/**
+ * The current request.
+ *
+ * @var \Symfony\Component\HttpFoundation\Request
+ */
+ protected $request;
+
+ /**
* Creates a SystemBrandingBlock instance.
*
* @param array $configuration
@@ -41,10 +57,16 @@ class SystemBrandingBlock extends BlockBase implements ContainerFactoryPluginInt
* The plugin implementation definition.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The factory for configuration objects.
+ * @param \Drupal\Core\Routing\UrlGeneratorInterface $url_generator
+ * The url generator service.
+ * @param \Symfony\Component\HttpFoundation\Request
+ * The current request.
*/
- public function __construct(array $configuration, $plugin_id, array $plugin_definition, ConfigFactoryInterface $config_factory) {
+ public function __construct(array $configuration, $plugin_id, array $plugin_definition, ConfigFactoryInterface $config_factory, UrlGeneratorInterface $url_generator, Request $request) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->configFactory = $config_factory;
+ $this->urlGenerator = $url_generator;
+ $this->request = $request;
}
/**
@@ -55,11 +77,26 @@ public static function create(ContainerInterface $container, array $configuratio
$configuration,
$plugin_id,
$plugin_definition,
- $container->get('config.factory')
+ $container->get('config.factory'),
+ $container->get('url_generator'),
+ $container->get('request')
);
}
/**
+ * Generates a URL or path for a specific route based on the given parameters.
+ *
+ * @see \Drupal\Core\Routing\UrlGeneratorInterface::generateFromRoute() for
+ * details on the arguments, usage, and possible exceptions.
+ *
+ * @return string
+ * The generated URL for the given route.
+ */
+ public function url($route_name, $route_parameters = array(), $options = array()) {
+ return $this->urlGenerator->generateFromRoute($route_name, $route_parameters, $options);
+ }
+
+ /**
* {@inheritdoc}
*/
public function defaultConfiguration() {
@@ -75,6 +112,43 @@ public function defaultConfiguration() {
* {@inheritdoc}
*/
public function blockForm($form, &$form_state) {
+ // Get the theme.
+ if ($this->request->attributes->get('theme')) {
+ // Get the theme from request if available.
+ $theme = $this->request->attributes->get('theme');
+ }
+ else {
+ $theme = $form_state['block_theme'];
+ }
+
+ // Get permissions.
+ $administer_themes_access = \Drupal::currentUser()->hasPermission('administer themes');
+ $administer_site_configuration_access = \Drupal::currentUser()->hasPermission('administer site configuration');
+
+ if ($administer_themes_access) {
+ // Get paths to theme settings pages.
+ $appearance_url = $this->url('system.themes_page');
+ $theme_settings_url = $this->url('system.theme_settings_theme', array('theme' => $theme));
+
+ // Provide links to the Appearance and Theme Settings pages if user has access to administer themes.
+ $site_logo_description = $this->t('Defined on the Appearance or Theme Settings page.', array('@appearance' => $appearance_url, '@theme' => $theme_settings_url));
+ } else {
+ // Explain that user does not have access to the Appearance and Theme Settings pages.
+ $site_logo_description = $this->t('Defined on the Appearance or Theme Settings page. You do not have the appropriate permissions to change the site logo.');
+ }
+ if ($administer_site_configuration_access) {
+ // Get paths to settings pages.
+ $site_information_url = $this->url('system.site_information_settings');
+
+ // Provide link to Site Information page if user has access to administer site configuration.
+ $site_name_description = $this->t('Defined on the Site Information page.', array('@information' => $site_information_url));
+ $site_slogan_description = $this->t('Defined on the Site Information page.', array('@information' => $site_information_url));
+ } else {
+ // Explain that user does not have access to the Site Information page.
+ $site_name_description = $this->t('Defined on the Site Information page. You do not have the appropriate permissions to change the site logo.');
+ $site_slogan_description = $this->t('Defined on the Site Information page. You do not have the appropriate permissions to change the site logo.');
+ }
+
$form['block_branding'] = array(
'#type' => 'details',
'#title' => $this->t('Toggle branding elements'),
@@ -85,19 +159,20 @@ public function blockForm($form, &$form_state) {
$form['block_branding']['use_site_logo'] = array(
'#type' => 'checkbox',
'#title' => $this->t('Site logo'),
- '#description' => $this->t('Defined in Appearance or theme settings.'),
+ '#description' => $site_logo_description,
'#default_value' => $this->configuration['use_site_logo'],
);
+
$form['block_branding']['use_site_name'] = array(
'#type' => 'checkbox',
'#title' => $this->t('Site name'),
- '#description' => $this->t('Defined in Site information settings.'),
+ '#description' => $site_name_description,
'#default_value' => $this->configuration['use_site_name'],
);
$form['block_branding']['use_site_slogan'] = array(
'#type' => 'checkbox',
'#title' => $this->t('Site slogan'),
- '#description' => $this->t('Defined in Site information settings.'),
+ '#description' => $site_slogan_description,
'#default_value' => $this->configuration['use_site_slogan'],
);
return $form;
diff --git a/core/modules/system/templates/branding.html.twig b/core/modules/system/templates/branding.html.twig
index 4b760be..36aa4f2 100644
--- a/core/modules/system/templates/branding.html.twig
+++ b/core/modules/system/templates/branding.html.twig
@@ -19,16 +19,11 @@
{% endif %}
-
-{% if use_site_name or (use_site_slogan and site_slogan) %}
-