You are here

private function FootnotesFilter::findFootnote in Footnotes 8.2

Search the $store_matches array for footnote text that matches.

Note: This does a linear search on the $store_matches array. For a large list of footnotes it would be more efficient to maintain a separate array with the footnote content as key, in order to do a hash lookup at this stage. Since you typically only have a handful of footnotes, this simple search is assumed to be more efficient, but was not tested.

Parameters

string $text: The footnote text.

array $store_matches: The matches array.

Return value

string|false The value of the existing footnote, FALSE otherwise.

1 call to FootnotesFilter::findFootnote()
FootnotesFilter::replaceCallback in src/Plugin/Filter/FootnotesFilter.php
Helper function called from preg_replace_callback() above.

File

src/Plugin/Filter/FootnotesFilter.php, line 367

Class

FootnotesFilter
Provides a base filter for Footnotes filter.

Namespace

Drupal\footnotes\Plugin\Filter

Code

private function findFootnote($text, array &$store_matches) {
  if (!empty($store_matches)) {
    foreach ($store_matches as &$fn) {
      if ($fn['text'] == $text) {
        return $fn['value'];
      }
    }
  }
  return FALSE;
}