public function DbReplacer::replaceAll in Convert Media Tags to Markup 8
Same name and namespace in other branches
- 2.x src/ConvertMediaTagsToMarkup/DbReplacer.php \Drupal\convert_media_tags_to_markup\ConvertMediaTagsToMarkup\DbReplacer::replaceAll()
Replace all instances of legacy media tags in the database to images.
Outputs the results using print_r(). This is designed to be used via drush.
Parameters
string $type: A type such as node.
string $bundle: A bundle such as article.
bool $simulate: Whether or not to Simulate the results.
string $log: For example "print_r" or "dpm".
File
- src/
ConvertMediaTagsToMarkup/ DbReplacer.php, line 44
Class
- DbReplacer
- Code to replace all code in the database.
Namespace
Drupal\convert_media_tags_to_markup\ConvertMediaTagsToMarkupCode
public function replaceAll(string $type, string $bundle, bool $simulate = TRUE, string $log = 'print_r') {
try {
foreach ($this
->getAllEntities($type, $bundle) as $entity) {
try {
$entity
->process($simulate, $log);
} catch (\Throwable $t) {
$this
->err($t
->getMessage(), $log);
}
}
} catch (\Throwable $t) {
$this
->err($t
->getMessage() . ' at ' . $t
->getFile() . ':' . $t
->getLine(), $log);
}
if (!empty($this->err)) {
$log('Exiting with error code 1 because at least one error occurred during processing.' . PHP_EOL);
exit(1);
}
}