public function ShortcodeBase::getAttributes in Shortcode 8
Same name and namespace in other branches
- 2.0.x src/Plugin/ShortcodeBase.php \Drupal\shortcode\Plugin\ShortcodeBase::getAttributes()
Combines user attributes with known attributes.
The $defaults should be considered to be all of the attributes which are supported by the caller and given as a list. The returned attributes will only contain the attributes in the $defaults list.
If the $attributes list has unsupported attributes, they will be ignored and removed from the final return list.
Parameters
array $defaults: Entire list of supported attributes and their defaults.
array $attributes: User defined attributes in Shortcode tag.
Return value
array Combined and filtered attribute list.
11 calls to ShortcodeBase::getAttributes()
- BlockShortcode::process in shortcode_basic_tags/
src/ Plugin/ Shortcode/ BlockShortcode.php - Performs the shortcode processing.
- BootstrapColumnShortcode::process in shortcode_example/
src/ Plugin/ Shortcode/ BootstrapColumnShortcode.php - Performs the shortcode processing.
- ButtonShortcode::process in shortcode_basic_tags/
src/ Plugin/ Shortcode/ ButtonShortcode.php - Performs the shortcode processing.
- ClearShortcode::process in shortcode_basic_tags/
src/ Plugin/ Shortcode/ ClearShortcode.php - Performs the shortcode processing.
- DropcapShortcode::process in shortcode_basic_tags/
src/ Plugin/ Shortcode/ DropcapShortcode.php - Performs the shortcode processing.
File
- src/
Plugin/ ShortcodeBase.php, line 172
Class
- ShortcodeBase
- Provides a base class for Shortcode plugins.
Namespace
Drupal\shortcode\PluginCode
public function getAttributes(array $defaults, array $attributes) {
$attributes = (array) $attributes;
$out = [];
foreach ($defaults as $name => $default) {
if (array_key_exists($name, $attributes)) {
$out[$name] = $attributes[$name];
}
else {
$out[$name] = $default;
}
}
return $out;
}