Commit bda7e94b authored by Markus Kalkbrenner's avatar Markus Kalkbrenner Committed by Markus Kalkbrenner
Browse files

Issue #3322928 by mkalkbrenner: Facets summary performance issues

parent 0453ca62
Loading
Loading
Loading
Loading
+3 −0
Changes for modules/facets_summary/config/schema/facets_summary.facets_summary.schema.yml: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -11,6 +11,9 @@ facets_summary.facets_summary.*:
    facet_source_id:
      type: string
      label: 'Facet source id'
    only_visible_when_facet_source_is_visible:
      type: boolean
      label: 'Show this summary only when the facet source is visible.'
    processor_configs:
      type: sequence
      label: 'Processor settings'
+0 −3
Changes for modules/facets_summary/config/schema/facets_summary.processor.schema.yml: 0 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -4,9 +4,6 @@ plugin.plugin_configuration.facets_summary_processor.show_summary:
plugin.plugin_configuration.facets_summary_processor.show_count:
  type: config_object

plugin.plugin_configuration.facets_summary_processor.hide_when_not_rendered:
  type: config_object

plugin.plugin_configuration.facets_summary_processor.show_text_when_empty:
  type: mapping
  label: 'No results behavior'
+21 −0
Changes for modules/facets_summary/facets_summary.install: 21 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -50,3 +50,24 @@ function facets_summary_update_8002(&$sandbox = NULL) {
    return $update;
  });
}

/**
 * Replace facet source rendered processor by facet summary property.
 */
function facets_summary_update_8003(&$sandbox = NULL) {
  \Drupal::classResolver(ConfigEntityUpdater::class)->update($sandbox, 'facets_summary', function ($facets_summary) {
    $update = FALSE;

    if ($facets_summary instanceof FacetsSummaryInterface) {
      $processor_settings = $facets_summary->getProcessorConfigs();

      if (isset($processor_settings['hide_when_not_rendered'])) {
        $facets_summary->setOnlyVisibleWhenFacetSourceIsVisible(TRUE);
        $facets_summary->removeProcessor('hide_when_not_rendered');
        $update = TRUE;
      }
    }

    return $update;
  });
}
+25 −0
Changes for modules/facets_summary/src/Entity/FacetsSummary.php: 25 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ use Drupal\facets_summary\FacetsSummaryInterface;
 *     "name",
 *     "facets",
 *     "facet_source_id",
 *     "only_visible_when_facet_source_is_visible",
 *     "processor_configs",
 *   },
 *   links = {
@@ -107,6 +108,16 @@ class FacetsSummary extends ConfigEntityBase implements FacetsSummaryInterface {
   */
  protected $weight;

  /**
   * Is the facet only visible when the facet source is only visible.
   *
   * A boolean that defines if the facet summary is only visible when the facet
   * source is visible.
   *
   * @var bool
   */
  protected $only_visible_when_facet_source_is_visible = FALSE;

  /**
   * {@inheritdoc}
   */
@@ -256,6 +267,20 @@ class FacetsSummary extends ConfigEntityBase implements FacetsSummaryInterface {
    return $return_processors;
  }

  /**
   * {@inheritdoc}
   */
  public function setOnlyVisibleWhenFacetSourceIsVisible($only_visible_when_facet_source_is_visible) {
    $this->only_visible_when_facet_source_is_visible = $only_visible_when_facet_source_is_visible;
  }

  /**
   * {@inheritdoc}
   */
  public function getOnlyVisibleWhenFacetSourceIsVisible() {
    return $this->only_visible_when_facet_source_is_visible;
  }

  /**
   * {@inheritdoc}
   */
+17 −0
Changes for modules/facets_summary/src/FacetsSummaryInterface.php: 17 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -120,6 +120,23 @@ interface FacetsSummaryInterface extends ConfigEntityInterface {
   */
  public function getProcessorConfigs();

  /**
   * Sets the "only visible when facet source is visible" boolean flag.
   *
   * @param bool $only_visible_when_facet_source_is_visible
   *   A boolean flag indicating if the facet should be hidden on a page that
   *   does not show the facet source.
   */
  public function setOnlyVisibleWhenFacetSourceIsVisible($only_visible_when_facet_source_is_visible);

  /**
   * Returns the "only visible when facet source is visible" boolean flag.
   *
   * @return bool
   *   True when the facet is only shown on a page with the facet source.
   */
  public function getOnlyVisibleWhenFacetSourceIsVisible();

  /**
   * Adds a processor for this facet.
   *
Loading