0

I wrote a custom source plugin and put it in migd8_node_blog/src/Plugin/migrate/source/Node.php with

<?php
 
/**
 * @file
 * Contains \Drupal\migd8_node_blog\Plugin\migrate\source\Node.
 */
 
namespace Drupal\migd8_node_blog\Plugin\migrate\source;
 
use Drupal\migrate\Row;
use Drupal\node\Plugin\migrate\source\d7\Node as D7Node;

    /**
     * Custom node source including url aliases.
     *
     * @MigrateSource(
     *   id = "migd8_node_blog_node"
     * )
     */
    
    class Node extends D7Node {

but i keep getting this error when i run drush mim migd8_node_blog Drupal\Component\Plugin\Exception\PluginNotFoundException: The "migd8_node_blog_node" plugin does not exist. even after flushing the cache and reinstalling the module.

9
  • Did you add a correct namespace matching the machine name of your module?
    – Hudri
    Oct 28, 2020 at 19:38
  • yes namespace Drupal\migd8_node_blog\Plugin\migrate\source;
    – Diana
    Oct 28, 2020 at 19:39
  • 1
    And the casing's right on the file/class names? For node.php the class would be node, not Node, for example. Or if the class is Node the filename needs to be Node.php depending on how you want to look at it
    – Clive
    Oct 28, 2020 at 19:40
  • yes class Node extends D7Node { the file name is Node.php
    – Diana
    Oct 28, 2020 at 19:47
  • 3
    Two last things that I'd add - firstly what are you running to get the error (presumably drush mim but being explicit is good), and I'd confirm that the path you've provided to the file is relative to module/src. Hopefully after that the downvoters will revisit and reconsider, as it would then be a good question IMO
    – Clive
    Oct 28, 2020 at 20:01

1 Answer 1

2

after flushing the cache and reinstalling the module

Check that the module is indeed installed at /admin/modules, if it's not, it's due to a migrate tools bug. Perhaps you deleted the part

dependencies:
  enforced:
    module:
      - migd8_node_blog

that you have in your other question, which fixes the reinstall bug if you have it before you install the module.

But if you installed it without the above code, you'll have to run this code once/one time only, and it will allow you to install again as this code removes the stuck configuration.

  $module_path = DRUPAL_ROOT . base_path() . drupal_get_path('module', 'migd8_node_blog') . '/config/install';

  $configs = array();
  $files = file_scan_directory($module_path, '/migrate_plus/');
  if ($files) {
    foreach ($files as $file) {
      $configs[] = $file->name;
    }
    // Delete each config using configFactory.
    foreach ($configs as $config_name) {
     \Drupal::configFactory()->getEditable($config_name)->delete();
    }

    return TRUE;
  }

If the modue is indeed installed, then the issue is due to you trying to assign migd8_node_blog_node as a plugin under the wrong key.

Since this is a source plugin and should be used only be used under source: and not/never under process: or any other key. See my answer.

2
  • id: migd8_node_blog label: Custom node migration from Drupal 7 migration_group: cncs dependencies: enforced: module: - migd8_node_blog_node source: plugin: migd8_node_blog_node node_type: blog_entry destination: plugin: entity:node bundle: blog
    – Diana
    Oct 29, 2020 at 13:30
  • okay as in the previous question after uniinstalling and reinsalling the module and deleting the configuration it finally worked.
    – Diana
    Oct 29, 2020 at 14:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.