Commit 62430b71 authored by catch's avatar catch
Browse files

Issue #2268787 by tim.plunkett: Block plugin forms should not rely on being...

Issue #2268787 by tim.plunkett: Block plugin forms should not rely on being called from \Drupal\block\BlockForm
parent 5b5988c8
Loading
Loading
Loading
Loading
+2 −7
Changes for core/modules/block/src/BlockForm.php: 2 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -118,12 +118,6 @@ public static function create(ContainerInterface $container) {
  public function form(array $form, FormStateInterface $form_state) {
    $entity = $this->entity;

    // Store theme settings in $form_state for use below.
    if (!$theme = $entity->getTheme()) {
      $theme = $this->config('system.theme')->get('default');
    }
    $form_state->set('block_theme', $theme);

    // Store the gathered contexts in the form state for other objects to use
    // during form building.
    $form_state->setTemporaryValue('gathered_contexts', $this->contextRepository->getAvailableContexts());
@@ -150,13 +144,14 @@ public function form(array $form, FormStateInterface $form_state) {
    ];

    // Theme settings.
    if ($entity->getTheme()) {
    if ($theme = $entity->getTheme()) {
      $form['theme'] = [
        '#type' => 'value',
        '#value' => $theme,
      ];
    }
    else {
      $theme = $this->config('system.theme')->get('default');
      $theme_options = [];
      foreach ($this->themeHandler->listInfo() as $theme_name => $theme_info) {
        if (!empty($theme_info->status)) {
+6 −11
Changes for core/modules/system/src/Plugin/Block/SystemBrandingBlock.php: 6 added lines, 11 removed lines.
Original line number Diff line number Diff line
@@ -75,19 +75,14 @@ public function defaultConfiguration() {
   * {@inheritdoc}
   */
  public function blockForm($form, FormStateInterface $form_state) {
    // Get the theme.
    $theme = $form_state->get('block_theme');

    // Get permissions.
    $url_system_theme_settings = new Url('system.theme_settings');
    $url_system_theme_settings_theme = new Url('system.theme_settings_theme', ['theme' => $theme]);

    if ($url_system_theme_settings->access() && $url_system_theme_settings_theme->access()) {
      // Provide links to the Appearance Settings and Theme Settings pages
      // if the user has access to administer themes.
      $site_logo_description = $this->t('Defined on the <a href=":appearance">Appearance Settings</a> or <a href=":theme">Theme Settings</a> page.', [
        ':appearance' => $url_system_theme_settings->toString(),
        ':theme' => $url_system_theme_settings_theme->toString(),

    if ($url_system_theme_settings->access()) {
      // Provide links to the Appearance Settings page if the user has access to
      // administer themes.
      $site_logo_description = $this->t('Defined on the <a href="@appearance">Appearance Settings</a> page.', [
        '@appearance' => $url_system_theme_settings->toString(),
      ]);
    }
    else {