trait HelperTrait in Bootstrap Styles 1.0.x
A Trait for helper methods.
Hierarchy
- trait \Drupal\bootstrap_styles\HelperTrait
1 file declares its use of HelperTrait
- StylesGroupPluginBase.php in src/
StylesGroup/ StylesGroupPluginBase.php
File
- src/
HelperTrait.php, line 10
Namespace
Drupal\bootstrap_stylesView source
trait HelperTrait {
/**
* Generates the svg markup from path.
*
* @param string $path
* The path to the svg icon.
*
* @return array
* Array of the SVG icon markup.
*/
public function getSvgIconMarkup(string $path) {
$svg = file_get_contents(DRUPAL_ROOT . '/' . $path);
$svg = preg_replace([
'/<\\?xml.*\\?>/i',
'/<!DOCTYPE((.|\\n|\\r)*?)">/i',
], '', $svg);
$svg = trim($svg);
return Markup::create($svg);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
HelperTrait:: |
public | function | Generates the svg markup from path. |