Verified Commit 675323e9 authored by Justin Wong's avatar Justin Wong
Browse files

Issue #2849349 by Wongjn: Remove redundant analysis code

parent 206e9b61
Loading
Loading
Loading
Loading
+0 −1
Changes for config/install/views.view.entity_pager_example.yml: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -62,7 +62,6 @@ display:
          display_count: true
          show_disabled_links: true
          circular_paging: false
          log_performance: true
      row:
        type: fields
      fields:
+0 −3
Changes for config/schema/entity_pager.views.schema.yml: 0 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -31,6 +31,3 @@ views.style.entity_pager:
    circular_paging:
      type: boolean
      label: 'Circular paging'
    log_performance:
      type: boolean
      label: 'Log performance suggestions'
+23 −0
Changes for entity_pager.install: 23 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -33,3 +33,26 @@ function entity_pager_update_8101() {
    }
  }
}

/**
 * Removes obsolete log performance option from entity_pager views.
 */
function entity_pager_update_20001() {
  $config_factory = \Drupal::configFactory();
  foreach ($config_factory->listAll('views.view.') as $view_config_name) {
    $save = FALSE;
    $view = $config_factory->getEditable($view_config_name);
    $displays = $view->get('display');
    foreach ($displays as &$display) {
      $style = $display['display_options']['style'] ?? [];
      if (($style['type'] ?? '') == 'entity_pager' && isset($style['options']['log_performance'])) {
        unset($display['display_options']['style']['options']['log_performance']);
        $save = TRUE;
      }
    }
    if ($save) {
      $view->set('display', $displays);
      $view->save(TRUE);
    }
  }
}

src/EntityPagerAnalyzer.php

deleted100644 → 0
+0 −44
Changes for src/EntityPagerAnalyzer.php: 0 added lines, 44 removed lines.
Original line number Diff line number Diff line
<?php

namespace Drupal\entity_pager;

use Drupal\entity_pager\Event\EntityPagerAnalyzeEvent;
use Drupal\entity_pager\Event\EntityPagerEvents;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

/**
 * A class for analyzing an entity pager and providing feedback.
 */
class EntityPagerAnalyzer implements EntityPagerAnalyzerInterface {

  /**
   * The event dispatcher.
   *
   * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface
   */
  protected $eventDispatcher;

  /**
   * Constructs a new EntityPagerAnalyzer object.
   *
   * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
   *   The event dispatcher.
   */
  public function __construct(EventDispatcherInterface $event_dispatcher) {
    $this->eventDispatcher = $event_dispatcher;
  }

  /**
   * {@inheritdoc}
   */
  public function analyze(EntityPagerInterface $entity_pager) {
    $event = new EntityPagerAnalyzeEvent($entity_pager);
    $this->eventDispatcher->dispatch(EntityPagerEvents::ENTITY_PAGER_ANALYZE, $event);
    $logs = $event->getLogs();

    foreach ($logs as $message) {
      \Drupal::logger('entity_pager')->notice($message);
    }
  }

}
+0 −18
Changes for src/EntityPagerAnalyzerInterface.php: 0 added lines, 18 removed lines.
Original line number Diff line number Diff line
<?php

namespace Drupal\entity_pager;

/**
 * An interface for an Entity Pager Analyzer.
 */
interface EntityPagerAnalyzerInterface {

  /**
   * Analyzes the given entity pager.
   *
   * @param \Drupal\entity_pager\EntityPagerInterface $entity_pager
   *   The entity pager to analyze.
   */
  public function analyze(EntityPagerInterface $entity_pager);

}
Loading