diff --git a/core/modules/block/lib/Drupal/block/BlockFormController.php b/core/modules/block/lib/Drupal/block/BlockFormController.php
index 2d74a70..1b6e473 100644
--- a/core/modules/block/lib/Drupal/block/BlockFormController.php
+++ b/core/modules/block/lib/Drupal/block/BlockFormController.php
@@ -95,10 +95,7 @@ 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 {
+ if (!$theme = $entity->get('theme')) {
$theme = $this->configFactory->get('system.theme')->get('default');
}
$form_state['block_theme'] = $theme;
@@ -239,7 +236,7 @@ public function form(array $form, array &$form_state) {
);
// Theme settings.
- if ($theme = $entity->get('theme')) {
+ if ($entity->get('theme')) {
$form['theme'] = array(
'#type' => 'value',
'#value' => $theme,
@@ -263,7 +260,6 @@ public function form(array $form, array &$form_state) {
),
);
}
- $form_state['block_theme'] = $theme;
// Region settings.
$form['region'] = array(
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockSystemBrandingTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockSystemBrandingTest.php
index 38f78b9..192d8fc 100644
--- a/core/modules/block/lib/Drupal/block/Tests/BlockSystemBrandingTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockSystemBrandingTest.php
@@ -19,6 +19,9 @@ class BlockSystemBrandingTest extends BlockTestBase {
*/
public static $modules = array('block', 'system');
+ /**
+ * {@inheritdoc}
+ */
public static function getInfo() {
return array(
'name' => 'System Branding Block',
@@ -27,7 +30,10 @@ public static function getInfo() {
);
}
- function setUp() {
+ /**
+ * {@inheritdoc}
+ */
+ public function setUp() {
parent::setUp();
// Set a site slogan.
\Drupal::config('system.site')
@@ -40,7 +46,7 @@ function setUp() {
/**
* Tests system branding block configuration.
*/
- function testSystemBrandingSettings() {
+ public function testSystemBrandingSettings() {
$site_logo_xpath = '//div[@id="block-site-branding"]//a[@class="site-logo"]';
$site_name_xpath = '//div[@id="block-site-branding"]//div[@class="site-name"]';
$site_slogan_xpath = '//div[@id="block-site-branding"]//div[@class="site-slogan"]';
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 9753ab0..437f4d0 100644
--- a/core/modules/system/lib/Drupal/system/Plugin/Block/SystemBrandingBlock.php
+++ b/core/modules/system/lib/Drupal/system/Plugin/Block/SystemBrandingBlock.php
@@ -11,9 +11,9 @@
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Routing\UrlGeneratorInterface;
+use Drupal\Core\Session\AccountInterface;
use Drupal\Component\Utility\Xss;
use Symfony\Component\DependencyInjection\ContainerInterface;
-use Symfony\Component\HttpFoundation\Request;
/**
* Provides a block to display 'Site branding' elements.
@@ -40,11 +40,11 @@ class SystemBrandingBlock extends BlockBase implements ContainerFactoryPluginInt
protected $configFactory;
/**
- * The current request.
+ * The current user.
*
- * @var \Symfony\Component\HttpFoundation\Request
+ * @var \Drupal\Core\Session\AccountInterface
*/
- protected $request;
+ protected $current_user;
/**
* Creates a SystemBrandingBlock instance.
@@ -59,14 +59,14 @@ class SystemBrandingBlock extends BlockBase implements ContainerFactoryPluginInt
* The factory for configuration objects.
* @param \Drupal\Core\Routing\UrlGeneratorInterface $url_generator
* The url generator service.
- * @param \Symfony\Component\HttpFoundation\Request
- * The current request.
+ * @param \Drupal\Core\Session\AccountInterface $current_user
+ * The current user.
*/
- public function __construct(array $configuration, $plugin_id, array $plugin_definition, ConfigFactoryInterface $config_factory, UrlGeneratorInterface $url_generator, Request $request) {
+ public function __construct(array $configuration, $plugin_id, array $plugin_definition, ConfigFactoryInterface $config_factory, UrlGeneratorInterface $url_generator, AccountInterface $current_user) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->configFactory = $config_factory;
$this->urlGenerator = $url_generator;
- $this->request = $request;
+ $this->currentUser = $current_user;
}
/**
@@ -79,24 +79,11 @@ public static function create(ContainerInterface $container, array $configuratio
$plugin_definition,
$container->get('config.factory'),
$container->get('url_generator'),
- $container->get('request')
+ $container->get('current_user')
);
}
/**
- * 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() {
@@ -113,37 +100,33 @@ public function defaultConfiguration() {
*/
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'];
- }
+ $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');
+ $administer_themes_access = $this->currentUser->hasPermission('administer themes');
+ $administer_site_configuration_access = $this->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));
+ $appearance_url = $this->urlGenerator->generateFromRoute('system.themes_page');
+ $theme_settings_url = $this->urlGenerator->generateFromRoute('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 {
+ }
+ 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');
+ $site_information_url = $this->urlGenerator->generateFromRoute('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 {
+ }
+ 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.');
@@ -191,6 +174,7 @@ public function blockSubmit($form, &$form_state) {
* {@inheritdoc}
*/
public function build() {
+
$build = array();
$site_config = $this->configFactory->get('system.site');
$build['#theme'] = 'branding';