Problem/Motivation
LeafletMap::getPopupContent() expects the passed in entity ID to always be a string, but this causes a fatal type error for entity types that use integer IDs:
TypeError: Drupal\leaflet_views\Plugin\views\style\LeafletMap::getPopupContent(): Argument #2 ($entity_id) must be of type string, int given, called in /leaflet/modules/leaflet_views/src/Plugin/views/style/LeafletMap.php on line 1123 in Drupal\leaflet_views\Plugin\views\style\LeafletMap->getPopupContent() (line 1235 of /leaflet/modules/leaflet_views/src/Plugin/views/style/LeafletMap.php).
EntityInterface::id() allows returning both string and integer IDs:
/**
* Gets the identifier.
*
* @return string|int|null
* The entity identifier, or NULL if the object does not yet have an
* identifier.
*/
public function id();
Code path is as follows:
LeafletMap::processGeofield()calls::extractEntityDetails()ExtractEntityDetails()retrieves the entity ID by calling$entity->id()(which is an integer) and returns it in the$detailsarray.LeafletMap::processGeofield()then calls::processEntityFeatures(), passing$details.::processEntityFeatures()unpacks the$detailsand passes the integer$entity_idto::getPopupContent()which accepts only strings.
Steps to reproduce
- Add a geofield to an entity type that uses integer IDs.
- Create a view that lists the entities and set it to display as a Leaflet Map.
- Render the view.
Proposed resolution
Change the signature of ::getPopupContent() to accept also integer values for the entity ID.
Issue fork leaflet-3592904
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
pfrenssenComment #4
itamair commentedthx @pfrenssen ... merged. Will be part of next Leaflet module release.