You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.3 KiB
40 lines
1.3 KiB
<?php |
|
|
|
/** |
|
* @file |
|
* Contains facet_field_formatter.module. |
|
*/ |
|
|
|
use Drupal\Core\Routing\RouteMatchInterface; |
|
|
|
/** |
|
* Implements hook_help(). |
|
*/ |
|
function solr_facet_field_formatter_help($route_name, RouteMatchInterface $route_match) { |
|
switch ($route_name) { |
|
// Main module help for the solr_facet_field_formatter module. |
|
case 'help.page.solr_facet_field_formatter': |
|
$output = ''; |
|
$output .= '<h3>' . t('About') . '</h3>'; |
|
$output .= '<p>' . t('Format string and text fields to link to Solr facet searches') . '</p>'; |
|
return $output; |
|
|
|
default: |
|
} |
|
} |
|
|
|
/** |
|
* Implements hook_field_formatter_info_alter(). |
|
* |
|
* Makes the Solr facet formatter available for every field type. The value |
|
* sent to the facet search is resolved per field type inside the formatter |
|
* (the referenced entity's label for reference fields such as entity_reference |
|
* and typed_relation, the field's main property value otherwise), so the facet |
|
* is filtered by the human readable value rather than an internal id. |
|
*/ |
|
function solr_facet_field_formatter_field_formatter_info_alter(array &$info) { |
|
if (isset($info['solr_facet_text_field_formatter'])) { |
|
$field_types = array_keys(\Drupal::service('plugin.manager.field.field_type')->getDefinitions()); |
|
$info['solr_facet_text_field_formatter']['field_types'] = $field_types; |
|
} |
|
}
|
|
|