You are here

public function BUEditorToolbarWrapper::match in BUEditor 8

Same name and namespace in other branches
  1. 8.2 src/BUEditorToolbarWrapper.php \Drupal\bueditor\BUEditorToolbarWrapper::match()

Returns items that start with a string or match a regex.

File

src/BUEditorToolbarWrapper.php, line 72

Class

BUEditorToolbarWrapper
Defines a class that manages BUEditor toolbar data.

Namespace

Drupal\bueditor

Code

public function match($str, $is_regex = FALSE) {
  $items = [];
  if ($this->assocToolbar) {
    foreach ($this->assocToolbar as $id) {
      $found = $is_regex ? preg_match($str, $id) : strpos($id, $str) === 0;
      if ($found) {
        $items[$id] = $id;
      }
    }
  }
  return $items;
}