-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace deprecation for search_api. (#455)
* Replace deprecation for search_api. * fixup! Replace deprecation for search_api. * Change constant to use strings. * Remove deprecated hook. --------- Co-authored-by: Mark Hanna <[email protected]>
- Loading branch information
1 parent
2bfacc1
commit f58ed62
Showing
3 changed files
with
43 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Drupal\civicrm_entity\EventSubscriber; | ||
|
||
use Drupal\search_api\Event\GatheringPluginInfoEvent; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
use Drupal\civicrm_entity\Plugin\search_api\datasource\CivicrmEntity as DatasourceCivicrmEntity; | ||
|
||
/** | ||
* CiviCRM Entity event subscriber. | ||
*/ | ||
class SearchApiSubscriber implements EventSubscriberInterface { | ||
|
||
/** | ||
* Gathering plugin info event handler. | ||
* | ||
* @param \Drupal\search_api\Event\GatheringPluginInfoEvent $event | ||
* Gathering info event. | ||
*/ | ||
public function onGatheringDataSources(GatheringPluginInfoEvent $event) { | ||
foreach ($event->getDefinitions() as $entity_type => &$definition) { | ||
if (strpos($entity_type, 'entity:civicrm_') !== FALSE) { | ||
unset($definition['deriver']); | ||
$definition['class'] = DatasourceCivicrmEntity::class; | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function getSubscribedEvents() { | ||
return [ | ||
'search_api.gathering_data_sources' => ['onGatheringDataSources'], | ||
]; | ||
} | ||
|
||
} |