Commit c9fbf625 authored by Tatiana Kiseleva's avatar Tatiana Kiseleva Committed by Markus Kalkbrenner
Browse files

[#3264196] Add in preview context for facet summary block.

parent dbc7ac2b
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -84,6 +84,11 @@ class FacetsSummaryBlock extends BlockBase implements FacetsSummaryBlockInterfac
   * {@inheritdoc}
   */
  public function build() {
    // Do not build the facet summary if the block is being previewed.
    if ($this->getContextValue('in_preview')) {
      return [];
    }

    /** @var \Drupal\facets_summary\FacetsSummaryInterface $summary */
    $facets_summary = $this->getEntity();

@@ -124,4 +129,11 @@ class FacetsSummaryBlock extends BlockBase implements FacetsSummaryBlockInterfac
    return [];
  }

  /**
   * {@inheritdoc}
   */
  public function getPreviewFallbackString() {
    return $this->t('Placeholder for the "@facet_summary" facet summary', ['@facet_summary' => $this->getDerivativeId()]);
  }

}
+4 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Drupal\facets_summary\Plugin\Block;

use Drupal\Core\Plugin\Context\ContextDefinition;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\Plugin\PluginBase;
@@ -63,6 +64,9 @@ class FacetsSummaryBlockDeriver implements ContainerDeriverInterface {
          'label' => $this->t('Facet Summary: :facet_summary', [':facet_summary' => $facets_summary->getName()]),
          'admin_label' => $facets_summary->getName(),
          'description' => $this->t('Facets Summary'),
          'context_definitions' => [
            'in_preview' => new ContextDefinition('string', $this->t('In preview'), FALSE),
          ],
        ] + $base_plugin_definition;
      }
      $this->derivatives[$base_plugin_id] = $plugin_derivatives;