0

I'm on drupal 8.7.1. Using following modules:

  • Migrate
  • Migrate Plus
  • Migrate Tools
  • Migrate Spreadsheet
  • Media & Media Library

I'm trying to import a bunch of profile images (as media images), located in assets/images/_smoelenboek directory in my custom module root. However I'm kind of lost on how I have to reference these files. The filename is listed in a spreadsheet file with the rest of the information about the profile.

The layout of the spreadsheet file:

ID | ... | Foto
----------------------
1  | ... | Foto1.jpg
...| ... | ...
25 | ... | Foto25.jpg

The layout of my migration file:

source:
  plugin: spreadsheet
  file: modules/custom/zedelgem_migrations/assets/xlsx/gebruikers_zedelgem_intranet.xlsx
  worksheet: 'Gebruikers'
  origin: A2
  header_row: 1
  columns:
    - ID
    - 'Foto'
    - 'Voornaam'
    - 'Achternaam'
  constants:
    file_source_uri: modules/custom/zedelgem_migrations/assets/images/_smoelenboek
  keys:
    ID:
      type: integer
      size: big
process:
  # Media bundle.
  bundle:
    plugin: default_value
    default_value: image
  uri:
      plugin: concat
      delimiter: /
      source:
        - constants/file_source_uri
        - 'Foto'
  name: 'Foto'
  uid: ID
  field_image/alt:
    plugin: concat
    source:
      - 'Voornaam'
      - 'Achternaam'
  field_image/title:
    plugin: concat
    source:
      - 'Voornaam'
      - 'Achternaam'
  field_image/target_id: 'Foto'
destination:
  plugin: entity:media
  default_bundle: image

The error I'm getting is:

[error] TypeError: Argument 2 passed to Drupal\migrate\Plugin\MigratePluginManager::createInstance() must be of the type array, null given, called in /var/www/html/web/core/modules/migrate/src/Plugin/Migration.php on line 372 in Drupal\migrate\Plugin\MigratePluginManager->createInstance() (line 52 of /var/www/html/web/core/modules/migrate/src/Plugin/MigratePluginManager.php) 0 /var/www/html/web/core/modules/migrate/src/Plugin/Migration.php(372): Drupal\migrate\Plugin\MigratePluginManager->createInstance(NULL, NULL, Object(Drupal\migrate\Plugin\Migration)) 1 /var/www/html/web/core/modules/migrate/src/MigrateExecutable.php(363): Drupal\migrate\Plugin\Migration->getProcessPlugins(Array) 2 /var/www/html/web/core/modules/migrate/src/MigrateExecutable.php(203): Drupal\migrate\MigrateExecutable->processRow(Object(Drupal\migrate\Row)) 3 /var/www/html/vendor/drush/drush/includes/drush.inc(223): Drupal\migrate\MigrateExecutable->import() 4 /var/www/html/vendor/drush/drush/includes/drush.inc(214): drush_call_user_func_array(Array, Array) 5 /var/www/html/web/modules/contrib/migrate_tools/src/Commands/MigrateToolsCommands.php(766): drush_op(Array) 6 [internal function]: Drupal\migrate_tools\Commands\MigrateToolsCommands->executeMigration(Object(Drupal\migrate\Plugin\Migration), 'images', Array) 7 /var/www/html/web/modules/contrib/migrate_tools/src/Commands/MigrateToolsCommands.php(321): array_walk(Array, Array, Array) 8 [internal function]: Drupal\migrate_tools\Commands\MigrateToolsCommands->import('images', Array) 9 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array(Array, Array) 10 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData)) 11 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(178): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData)) 12 /var/www/html/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(302): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData)) 13 /var/www/html/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 14 /var/www/html/vendor/symfony/console/Application.php(978): Symfony\Component\Console\Command\Command->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 15 /var/www/html/vendor/symfony/console/Application.php(255): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 16 /var/www/html/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 17 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 18 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(49): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput)) 19 /var/www/html/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run(Array) 20 /var/www/html/vendor/drush/drush/includes/preflight.inc(18): require('/var/www/html/v...') 21 phar:///usr/local/bin/drush/bin/drush.php(141): drush_main() 22 /usr/local/bin/drush(10): require('phar:///usr/loc...') 23 {main}.

If someone could point me in the right direction, that would be much appreciated!

  • I corrected the yaml for field_image/alt and field_image/title where I forgot to put plugin before the concat plugintype. I'm no longer getting the error listed in this post. Sadly I'm getting a new error Not saved in link table because the key field ID contains a NULL value. I checked the spreadsheet and all rows contain a unique ID so the problem lies somewhere in my YAML file. – Geordi Feijens May 20 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.