Commit 0a58c2f6 authored by Tim Plunkett's avatar Tim Plunkett Committed by Markus Kalkbrenner
Browse files

Issue #3027593 by mpotter, tim.plunkett, borisson_, mkalkbrenner: Empty facet...

Issue #3027593 by mpotter, tim.plunkett, borisson_, mkalkbrenner: Empty facet blocks with Layout Builder
parent 70665140
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -79,6 +79,11 @@ class FacetBlock extends BlockBase implements ContainerFactoryPluginInterface {
      return [];
    }

    // Do not build the facet if the block is being previewed.
    if ($this->getContextValue('in_preview')) {
      return [];
    }

    // Let the facet_manager build the facets.
    $build = $this->facetManager->build($facet);

@@ -173,4 +178,11 @@ class FacetBlock extends BlockBase implements ContainerFactoryPluginInterface {
    }
  }

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

}
+4 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Drupal\facets\Plugin\Block;

use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Plugin\Context\ContextDefinition;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -66,6 +67,9 @@ class FacetBlockDeriver implements ContainerDeriverInterface {
          'label' => $this->t('Facet: :facet', [':facet' => $facet->getName()]),
          'admin_label' => $facet->getName(),
          'description' => $this->t('Facet'),
          'context_definitions' => [
            'in_preview' => new ContextDefinition('string', $this->t('In preview'), FALSE),
          ],
        ] + $base_plugin_definition;
      }