0

My plugin aims to strip out html tags from titles being imported from xml Here is the error I'm receiving: FVFXF0ETHV2F:process k28002$ drush mim complinet_xml_to_node Drupal\Component\Plugin\Exception\PluginNotFoundException: The "stripouthtml" plugin does not exist. in [error] /Users/k28002/Sites/devdesktop/drupal8test/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php:52 Stack trace:

Here is the plugin which lives in custom/complinetmigration/src/Plugin/migrate/process

<?php

/**
 * @file
 * Contains \Drupal\complinetmigration\Plugin\migrate\process\StripOutHTML.
 */

namespace Drupal\complinetmigration\Plugin\migrate\process;

use Drupal\migrate\MigrateException;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;

 /**
 * @MigrateProcessPlugin(
 * id = "stripouthtml"
 * )
 *
 */
class StripOutHTML extends ProcessPluginBase {

  /**
   * {@inheritdoc}
   */
  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
    // $value: cut off .<nnn>Z and replace by Z
    if( is_null($value) )
    {
      return $value;
    }

    // $old = $value;

    $value= strip_tags($value);
    // drush_print_r( $old . ' -> ' . $value );

    return $value;
  }

}

and here is the migration

# This migration demonstrates importing from a monolithic XML file.
dependencies:
    enforced:
      module:
        - complinetmigration
id: complinet_xml_to_node
label: XML feed of nodes from complinet
migration_group: complinet
migration_tags:
  - advanced xml import
source:
  # We use the XML data parser plugin.
  plugin: url
  data_fetcher_plugin: http
  data_parser_plugin: xml
  # Normally, this is one or more fully-qualified URLs or file paths. Because
  # we can't hardcode your local URL, we provide a relative path here which
  # hook_install() will rewrite to a full URL for the current site.
  urls: private://FINRAManual08-08-18.xml
  #  - /migrate_example_advanced_position?_format=xml
  # Visit the URL above (relative to your site root) and look at it. You can see
  # that <response> is the outer element, and each item we want to import is a
  # <position> element. The item_xpath value is the xpath to use to query the
  # desired elements.
  item_selector: '/quickpipe/section/section/section'
  # Under 'fields', we list the data items to be imported. The first level keys
  # are the source field names we want to populate (the names to be used as
  # sources in the process configuration below). For each field we're importing,
  # we provide a label (optional - this is for display in migration tools) and
  # an xpath for retrieving that value. It's important to note that this xpath
  # is relative to the elements retrieved by item_xpath.
  fields:
    -
      name: versionid
      label: 'Version Id'
      selector: 'version[1]/@recordId'
    -
      name: title
      label: 'Title'
      selector: 'version[1]/title'
    -
      name: content
      lable: 'Content'
      selector: 'version[1]/content'

  # Under 'ids', we identify source fields populated above which will uniquely
  # identify each imported item. The 'type' makes sure the migration map table
  # uses the proper schema type for stored the IDs.
  ids:
    versionid:
      type: integer
destination:
  plugin: entity:node
process:
  # Hardcode the destination node type (bundle) as 'migrate_example_beer'.
  type:
    plugin: default_value
    default_value: article
  title:
    plugin: stripouthtml
    source: title
  uid:
    plugin: default_value
    default_value: 1
  sticky:
    plugin: default_value
    default_value: 0
  body: content
migration_dependencies: {}
  • The plugin filename is StripOutHTML.php . – barneytech Jan 8 at 15:22
  • How about structure of files? – Jonh Jan 8 at 16:01
  • @Jonh StripOutHTML.php with the plugin lives in modules/custom/complinetmigration/src/Plugin/migrate/process any other structure to contend with? – barneytech Jan 8 at 16:02
  • I just tested with annotation indent. Don't need tab 2 near id = "stripouthtml" but you can try it. And remember clear cache before run clear cache. – Jonh Jan 8 at 16:08
  • @Johh, so get rid of any spacing before id = "stripouthtml" and run drush cr right? – barneytech Jan 8 at 16:09
0

after doing the following based on the advice of @JonH to double check the module was installed correctly I found the following

FVFXF0ETHV2F:process k28002$ drush pm-uninstall complinetmigration
    complinetmigration is already uninstalled.                                                                                                       [ok]
    There were no extensions that could be uninstalled.                                                                                              [ok]
    FVFXF0ETHV2F:process k28002$ drush en complinetmigration
    The following extensions will be enabled: complinetmigration
    Do you really want to continue? (y/n): y
    Drupal\Core\Config\PreExistingConfigException: Configuration objects (migrate_plus.migration.complinet_xml_to_node) provided by                  [error]
    complinetmigration already exist in active configuration in
    /Users/k28002/Sites/devdesktop/drupal8test/core/lib/Drupal/Core/Config/PreExistingConfigException.php:65
    Stack trace:
    #0 /Users/k28002/Sites/devdesktop/drupal8test/core/lib/Drupal/Core/Config/ConfigInstaller.php(496):
    Drupal\Core\Config\PreExistingConfigException::create('complinetmigrat...', Array)
    #1 /Users/k28002/Sites/devdesktop/drupal8test/core/lib/Drupal/Core/ProxyClass/Config/ConfigInstaller.php(132):
    Drupal\Core\Config\ConfigInstaller->checkConfigurationToInstall('module', 'complinetmigrat...')
    #2 /Users/k28002/Sites/devdesktop/drupal8test/core/lib/Drupal/Core/Extension/ModuleInstaller.php(150):
    Drupal\Core\ProxyClass\Config\ConfigInstaller->checkConfigurationToInstall('module', 'complinetmigrat...')
    #3 /Users/k28002/Sites/devdesktop/drupal8test/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php(83):
    Drupal\Core\Extension\ModuleInstaller->install(Array, true)
    #4 /Applications/DevDesktop/tools/vendor/drush/drush/commands/core/drupal/environment.inc(131):
    Drupal\Core\ProxyClass\Extension\ModuleInstaller->install(Array, true)
    #5 /Applications/DevDesktop/tools/vendor/drush/drush/commands/core/drupal/environment.inc(198): drush_module_install(Array)
    #6 /Applications/DevDesktop/tools/vendor/drush/drush/commands/pm/pm.drush.inc(1180): drush_module_enable(Array)
    #7 /Applications/DevDesktop/tools/vendor/drush/drush/includes/command.inc(422): drush_pm_enable('complinetmigrat...')
    #8 /Applications/DevDesktop/tools/vendor/drush/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
    #9 /Applications/DevDesktop/tools/vendor/drush/drush/includes/command.inc(199): drush_command('complinetmigrat...')
    #10 /Applications/DevDesktop/tools/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
    #11 /Applications/DevDesktop/tools/vendor/drush/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
    #12 /Applications/DevDesktop/tools/vendor/drush/drush/drush.php(12): drush_main()
    #13 {main}
    FVFXF0ETHV2F:process k28002$ drush ev "\Drupal::service('config.manager')->uninstall('module', 'complinetmigration');"
    FVFXF0ETHV2F:process k28002$ drush en complinetmigration
    The following extensions will be enabled: complinetmigration
    Do you really want to continue? (y/n): y
    complinetmigration was enabled successfully.      

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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