function TipPluginBase::getAttributes
Same name in other branches
- 8.9.x core/modules/tour/src/TipPluginBase.php \Drupal\tour\TipPluginBase::getAttributes()
@todo remove in https://drupal.org/node/3195193
Overrides TipPluginInterface::getAttributes
1 call to TipPluginBase::getAttributes()
- TipPluginTextLegacy::getAttributes in core/
modules/ tour/ tests/ tour_test/ src/ Plugin/ tour/ tip/ TipPluginTextLegacy.php - @todo remove in https://drupal.org/node/3195193
1 method overrides TipPluginBase::getAttributes()
- TipPluginTextLegacy::getAttributes in core/
modules/ tour/ tests/ tour_test/ src/ Plugin/ tour/ tip/ TipPluginTextLegacy.php - @todo remove in https://drupal.org/node/3195193
File
-
core/
modules/ tour/ src/ TipPluginBase.php, line 79
Class
- TipPluginBase
- Defines a base tour item implementation.
Namespace
Drupal\tourCode
public function getAttributes() {
// This method is deprecated and rewritten to be as backwards compatible as
// possible with pre-existing uses. Due to the flexibility of tip plugins,
// this backwards compatibility can't be fully guaranteed. Because of this,
// we trigger a warning to caution the use of this function. This warning
// does not stop page execution, but will be logged.
trigger_error(__NAMESPACE__ . '\\TipPluginInterface::getAttributes is deprecated. Tour tip plugins should implement ' . __NAMESPACE__ . '\\TourTipPluginInterface and Tour configs should use the \'selector\' property instead of \'attributes\' to target an element.', E_USER_WARNING);
// The _tour_update_joyride() updates the deprecated 'attributes' property
// to the current 'selector' property. It's possible that additional
// attributes not supported by Drupal core exist and these need to merged
// in.
$attributes = $this->get('attributes') ?: [];
// Convert the selector property to the expected structure.
$selector = $this->get('selector');
$first_char = substr($selector, 0, 1);
if ($first_char === '#') {
$attributes['data-id'] = substr($selector, 1);
}
elseif ($first_char === '.') {
$attributes['data-class'] = substr($selector, 1);
}
return $attributes;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.