Commit 5e904ab3 authored by mxh's avatar mxh
Browse files

Issue #3294904 by mxh: Dependency calculation missing when using a text format

parent 2c7aecd6
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -55,8 +55,9 @@ class TextBlock extends BlockBase implements ContainerFactoryPluginInterface {
   */
  public function defaultConfiguration() {
    $default = ['text' => ['value' => NULL, 'format' => NULL]];
    if ($this->moduleHandler->moduleExists('filter')) {
      $default['text']['format'] = filter_default_format();
    $current_user = \Drupal::currentUser();
    if ($this->moduleHandler->moduleExists('filter') && filter_formats($current_user)) {
      $default['text']['format'] = filter_default_format($current_user);
    }
    return $default + parent::defaultConfiguration();
  }
@@ -108,4 +109,20 @@ class TextBlock extends BlockBase implements ContainerFactoryPluginInterface {
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function calculateDependencies() {
    $dependencies = parent::calculateDependencies();
    if ($this->moduleHandler->moduleExists('filter')) {
      $dependencies['module'][] = 'filter';
      if (isset($this->configuration['text']['format'])) {
        if ($config = \Drupal::entityTypeManager()->getStorage('filter_format')->load($this->configuration['text']['format'])) {
          $dependencies[$config->getConfigDependencyKey()][] = $config->getConfigDependencyName();
        }
      }
    }
    return $dependencies;
  }

}