Documentation

FindReplaceInterface

This is a base class for find-replace behaviours, aka. the doomtool.

Tags
see
FindReplace
FindReplaceText
FindReplaceWidget

Table of Contents

Methods

find()  : iterable<string|int, array<string|int, mixed>>
Find all occurrences of the the given string patterns.
getName()  : string
The friendly name for this doomtool shown in the dbtools.
key()  : string
The unique key for this doomtool.
replace()  : int
Find and replace all occurrences of the given string patterns.

Methods

find()

Find all occurrences of the the given string patterns.

public find(array<string|int, string> $finds, array<string|int, mixed> $settings) : iterable<string|int, array<string|int, mixed>>

The result set:

  • id: the record ID, if any
  • key: the replacer instance
  • text: the full text body in which the pattern was found
  • url: the URL to the record, if any
  • indexes: the character indexes of the matches
  • count: number of matches (should match indexes length)

The indexes are a list of [ start, length ] pairs. These can be used to highlight the matches in the text.

Parameters
$finds : array<string|int, string>

regex patterns

$settings : array<string|int, mixed>

[ ignore_case ]

Return values
iterable<string|int, array<string|int, mixed>> —

[ id, key, text, url, indexes, count ]

getName()

The friendly name for this doomtool shown in the dbtools.

public getName() : string

This should be unique enough to identify how the tool behaves.

Return values
string

key()

The unique key for this doomtool.

public key() : string

This should represent the class and any instance settings.

Wrap this in a UUIDv5 using the FindReplace::NAMESPACE to make it smaller and URL safe.

Return values
string

replace()

Find and replace all occurrences of the given string patterns.

public replace(array<string|int, string> $replaces, array<string|int, mixed> $settings) : int
Parameters
$replaces : array<string|int, string>

[ find => replace ] regex + replacements

$settings : array<string|int, mixed>

[ ignore_case ]

Return values
int —

number of replacements

On this page

Search results