-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
UHF-10774: Map searchapi types
Showing
3 changed files
with
44 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Drupal\helfi_platform_config\EventSubscriber; | ||
|
||
use Drupal\search_api\Event\MappingFieldTypesEvent; | ||
use Drupal\search_api\Event\SearchApiEvents; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
|
||
/** | ||
* Search api event subscriber. | ||
*/ | ||
final class SearchApiSubscriber implements EventSubscriberInterface { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function getSubscribedEvents(): array { | ||
// Bail if search_api is not installed. | ||
if (!class_exists(SearchApiEvents::class)) { | ||
return []; | ||
} | ||
|
||
return [ | ||
SearchApiEvents::MAPPING_FIELD_TYPES => 'mapFieldTypes', | ||
]; | ||
} | ||
|
||
/** | ||
* Map custom field types. | ||
*/ | ||
public function mapFieldTypes(MappingFieldTypesEvent $event): void { | ||
$mapping = &$event->getFieldTypeMapping(); | ||
$mapping['location'] = 'location'; | ||
} | ||
|
||
} |
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