How to exclude contents from migration I'm using Migrate to import entities.

I want to exclude rows based on a custom plugin (my source has a "url" field and I've to check if this url contains a "www.mysite.com" string: if not, the rows must be ignored).

How can I do this?
This hook might be the solution it excludes different contents from migrating:

function hook_migrate_prepare_row(Row $row, MigrateSourceInterface $source, MigrationInterface $migration) {
  // Ignore content types from being migrated.
  if ($migration-&gt;id() == 'd6_node_type') {
    $ignore_content_types = array('content_type1', 'content_type2');
    if (in_array($row-&gt;getSource()['type'], $ignore_content_types)) {
      return FALSE;
    }
  }

  // Ignoring content of 4 content types.
  $ignore_content_types_content = array('d6_node__content_type1', 'd6_node__content_type2');
  if (in_array($migration-&gt;id(), $ignore_content_types_content)) {
    return FALSE;
  }
}