From 91469ec5bf9f35e76c66b8d38aff633cfee05cff Mon Sep 17 00:00:00 2001 From: HongPong <hongpong@hongpong.com> Date: Mon, 31 Mar 2025 17:58:52 -0400 Subject: [PATCH] Issue #3491146 by ryumaou, HongPong: wordpress_migrate_log_term code cleanup. --- src/Plugin/migrate/process/LogTerm.php | 48 ++++++++++++++++---------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/src/Plugin/migrate/process/LogTerm.php b/src/Plugin/migrate/process/LogTerm.php index ba5a70c..10e77d1 100644 --- a/src/Plugin/migrate/process/LogTerm.php +++ b/src/Plugin/migrate/process/LogTerm.php @@ -1,50 +1,60 @@ <?php -/** - * Provides migrate process plugin "wordpress_migrate_log_term". Will log term - * ID, Name, Slug, Destination. - */ + namespace Drupal\wordpress_migrate\Plugin\migrate\process; use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\Row; -//use Drupal\migrate\MigrateSkipProcessException; + +// Use Drupal\migrate\MigrateSkipProcessException;. + +/** + * Provides migrate process plugin "wordpress_migrate_log_term". Will log term + * ID, Name, Slug, Destination. + */ /** -* @MigrateProcessPlugin( -* id = "wordpress_migrate_log_term" -* ) -*/ + * @MigrateProcessPlugin( + * id = "wordpress_migrate_log_term" + * ) + */ class LogTerm extends ProcessPluginBase { + + /** + * + */ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { $source = $row->getSource(); - // Get original values for debugging + // Get original values for debugging. $term_id = ''; $name = ''; $slug = ''; if (isset($source['tag_slug'])) { - // This is a tag + // This is a tag. $term_id = $source['term_id'] ?? 'unknown'; $name = $source['tag_name'] ?? 'unknown'; $slug = $source['tag_slug'] ?? 'unknown'; } elseif (isset($source['category_nicename'])) { - // This is a category + // This is a category. $term_id = $source['term_id'] ?? 'unknown'; $name = $source['cat_name'] ?? 'unknown'; $slug = $source['category_nicename'] ?? 'unknown'; } - \Drupal::logger('wordpress_migrate')->debug('Processing term: Term ID=@id, Name=@name, Slug=@slug, Destination=@dest, Value=@value', [ - '@id' => $term_id, - '@name' => $name, - '@slug' => $slug, - '@dest' => $destination_property, - '@value' => $value, - ]); + \Drupal::logger('wordpress_migrate')->debug( + 'Processing term: Term ID=@id, Name=@name, Slug=@slug, Destination=@dest, Value=@value', [ + '@id' => $term_id, + '@name' => $name, + '@slug' => $slug, + '@dest' => $destination_property, + '@value' => $value, + ] + ); return $value; } + } -- GitLab