Commit 918427a2 authored by itamair's avatar itamair
Browse files

- Better context property definition in MapThemer Plugins;

- Added the possibility to hide Default Icon rows rendering in Legend;
parent 70a95484
......@@ -47,7 +47,7 @@ class MapThemer extends Plugin {
/**
* The Geofield Map Themer plugin application context.
*
* @var string
* @var array
*/
public $context;
......
......@@ -70,6 +70,20 @@ abstract class MapThemerBase extends PluginBase implements MapThemerInterface, C
];
}
/**
* Define if to return the default Legend Icon.
*
* This might act on values to which no image/Managed_file has been input.
* This might be overridden by MapThemer plugins to alter this default
* behaviour.
*
* @return bool
* If the default Legend Icon cases/values should be listed in the legend.
*/
protected function renderDefaultLegendIcon() {
return TRUE;
}
/**
* Constructs a Drupal\Component\Plugin\PluginBase object.
*
......
......@@ -20,7 +20,7 @@ use Drupal\Core\Render\Markup;
* name = @Translation("Custom Icon Image File (Geofield Map)"),
* description = "This Geofield Map Themer allows the definition of a unique custom Marker Icon, valid for all the Map Markers.",
* type = "single_value",
* context = "ViewStyle",
* context = {"ViewStyle"},
* defaultSettings = {
* "values" = NULL
* },
......@@ -102,6 +102,7 @@ class CustomIconThemer extends MapThemerBase {
];
$fid = (integer) !empty($map_theming_values['icon_file']['fids']) ? $map_theming_values['icon_file']['fids'][0] : NULL;
$legend['custom-icon'] = [
'value' => [
'#type' => 'container',
......
......@@ -26,7 +26,7 @@ use Drupal\Core\Entity\EntityInterface;
* name = @Translation("Entity Type (Geofield Map)"),
* description = "This Geofield Map Themer allows the definition of different Marker Icons based on the View filtered Entity Types/Bundles.",
* type = "key_value",
* context = "ViewStyle",
* context = {"ViewStyle"},
* defaultSettings = {
* "values": {}
* },
......@@ -228,6 +228,12 @@ class EntityTypeThemer extends MapThemerBase {
$image_style = isset($map_theming_values[$bundle]['image_style']) ? $map_theming_values[$bundle]['image_style'] : 'none';
}
$fid = (integer) !empty($value['icon_file']['fids']) ? $value['icon_file']['fids'] : NULL;
// Don't render legend row in case no image is associated and the plugin
// denies to render the DefaultLegendIcon definition.
if (empty($fid) && !$this->renderDefaultLegendIcon()) {
continue;
}
$label = isset($value['label']) ? $value['label'] : $bundle;
$legend[$bundle] = [
'value' => [
......
......@@ -29,7 +29,7 @@ use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException;
* name = @Translation("Taxonomy Term (Geofield Map)"),
* description = "This Geofield Map Themer allows the definition of different Marker Icons based on Taxonomy Terms reference field in View.",
* type = "key_value",
* context = "ViewStyle",
* context = {"ViewStyle"},
* defaultSettings = {
* "values": {}
* },
......@@ -217,6 +217,7 @@ class TaxonomyTermThemer extends MapThemerBase {
'@file_upload_help' => $this->renderer->renderPlain($this->markerIcon->getFileUploadHelp()),
])),
$this->t('Icon Image Style'),
$this->t('Notes'),
],
'#tabledrag' => [[
'action' => 'order',
......@@ -320,6 +321,12 @@ class TaxonomyTermThemer extends MapThemerBase {
$image_style = isset($map_theming_values['fields'][$taxonomy_field]['terms'][$vid]['image_style']) ? $map_theming_values['fields'][$taxonomy_field]['terms'][$vid]['image_style'] : 'none';
}
$fid = (integer) !empty($term['icon_file']['fids']) ? $term['icon_file']['fids'] : NULL;
// Don't render legend row in case no image is associated and the plugin
// denies to render the DefaultLegendIcon definition.
if (empty($fid) && !$this->renderDefaultLegendIcon()) {
continue;
}
$label = isset($term['label']) ? $term['label'] : $vid;
$legend[$vid] = [
'value' => [
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment