public function FontFieldIconDefaultWidget::getIconsFromFile in Font Field Icon 8
Get CSS content from the file and return to the Icons select.
Return value
array Return icon.
1 call to FontFieldIconDefaultWidget::getIconsFromFile()
- FontFieldIconDefaultWidget::formElement in src/
Plugin/ Field/ FieldWidget/ FontFieldIconDefaultWidget.php - Returns the form for a single field widget.
File
- src/
Plugin/ Field/ FieldWidget/ FontFieldIconDefaultWidget.php, line 59
Class
- FontFieldIconDefaultWidget
- Plugin implementation of the 'FontFieldIconDefaultWidget' widget.
Namespace
Drupal\font_field_icon\Plugin\Field\FieldWidgetCode
public function getIconsFromFile() {
$filepath = DRUPAL_ROOT . '/libraries/fontawesome/css/font-awesome.css';
$content = file_exists($filepath) ? file_get_contents($filepath) : '';
if ($content) {
if (preg_match_all('@\\.fa-(.*?):before@m', $content, $matches)) {
$icons = $matches[1];
asort($icons);
return array_combine($icons, $icons);
}
else {
return [
'None' => 'Read readme file!',
];
}
}
else {
return [
'None' => 'Read readme file!',
];
}
}