Skip to content

Commit

Permalink
EWPP-2570: Rename event related to facet update.
Browse files Browse the repository at this point in the history
  • Loading branch information
sergepavle committed May 11, 2023
1 parent 6880420 commit edafd83
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
use Symfony\Component\EventDispatcher\Event;

/**
* Event fired when a facet is created from an open vocabularies association.
* Event fired when a facet is updated from an open vocabularies association.
*/
class AssociationFacetCreationEvent extends Event {
class AssociationFacetUpdateEvent extends Event {

/**
* The name of the event.
*/
const NAME = 'oe_list_pages_open_vocabularies.associated_facet_creation_event';
const NAME = 'oe_list_pages_open_vocabularies.associated_facet_update_event';

/**
* The created but not yet saved facet.
Expand All @@ -25,7 +25,7 @@ class AssociationFacetCreationEvent extends Event {
protected $facet;

/**
* AssociationFacetCreationEvent constructor.
* AssociationFacetUpdateEvent constructor.
*
* @param \Drupal\facets\FacetInterface $facet
* The created but not yet saved facet.
Expand All @@ -52,7 +52,7 @@ public function getFacet(): FacetInterface {
*
* @return $this
*/
public function setFacet(FacetInterface $facet): AssociationFacetCreationEvent {
public function setFacet(FacetInterface $facet): AssociationFacetUpdateEvent {
$this->facet = $facet;
return $this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Drupal\facets\FacetInterface;
use Drupal\language\Config\LanguageConfigOverride;
use Drupal\oe_list_pages\ListSourceFactoryInterface;
use Drupal\oe_list_pages_open_vocabularies\Event\AssociationFacetCreationEvent;
use Drupal\oe_list_pages_open_vocabularies\Event\AssociationFacetUpdateEvent;
use Drupal\open_vocabularies\OpenVocabularyAssociationInterface;
use Drupal\search_api\IndexInterface;
use Drupal\search_api\Item\Field;
Expand Down Expand Up @@ -145,8 +145,8 @@ public function updateConfig(OpenVocabularyAssociationInterface $association, st
$facet->setFieldIdentifier($property_path);

// Use event dispatching to allow alter facet config before saving.
$event = new AssociationFacetCreationEvent($facet);
$this->eventDispatcher->dispatch($event, AssociationFacetCreationEvent::NAME);
$event = new AssociationFacetUpdateEvent($facet);
$this->eventDispatcher->dispatch($event, AssociationFacetUpdateEvent::NAME);
$event->getFacet()->save();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Drupal\oe_list_pages_open_vocabularies_test\EventSubscriber;

use Drupal\oe_list_pages_open_vocabularies\Event\AssociationFacetCreationEvent;
use Drupal\oe_list_pages_open_vocabularies\Event\AssociationFacetUpdateEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
Expand All @@ -16,17 +16,17 @@ class SearchApiFacetTestSubscriber implements EventSubscriberInterface {
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[AssociationFacetCreationEvent::NAME] = 'onFacetUpdate';
$events[AssociationFacetUpdateEvent::NAME] = 'onFacetUpdate';
return $events;
}

/**
* Updates the open vocabulary facets before saving.
*
* @param \Drupal\oe_list_pages_open_vocabularies\Event\AssociationFacetCreationEvent $event
* @param \Drupal\oe_list_pages_open_vocabularies\Event\AssociationFacetUpdateEvent $event
* The Search API Facet update event.
*/
public function onFacetUpdate(AssociationFacetCreationEvent $event) {
public function onFacetUpdate(AssociationFacetUpdateEvent $event) {
$facet = $event->getFacet();
$settings = [
'behavior' => 'text',
Expand Down

0 comments on commit edafd83

Please sign in to comment.