public function Entity::replace in Search and Replace Scanner 8
Performs the replace operation for the given string/expression.
Parameters
string $field: The field with the matching string (formatted as type:bundle:field).
array $values: An array containing the $form_state values.
array $undo_data: An array containing the data.
Return value
array An array containing the revisoion ids of the affected entities.
Overrides ScannerPluginBase::replace
2 methods override Entity::replace()
- Node::replace in src/
Plugin/ Scanner/ Node.php - Performs the replace operation for the given string/expression.
- Paragraph::replace in src/
Plugin/ Scanner/ Paragraph.php - Performs the replace operation for the given string/expression.
File
- src/
Plugin/ Scanner/ Entity.php, line 77
Class
- Entity
- Class Entity.
Namespace
Drupal\scanner\Plugin\ScannerCode
public function replace($field, array $values, array $undo_data) {
$data = [];
list($entityType) = explode(':', $field);
try {
$plugin = $this->scannerManager
->createInstance("scanner_{$entityType}");
} catch (PluginException $e) {
// The instance could not be found so fail gracefully and let the user
// know.
\Drupal::logger('scanner')
->error($e
->getMessage());
\Drupal::messenger()
->addError('An error occured: ' . $e
->getMessage());
}
// Perform the replace on the current field and save results.
$results = $plugin
->replace($field, $values, $undo_data);
if (!empty($results)) {
$data = $results;
}
return $data;
}