Skip to content
Snippets Groups Projects

Issue #3229479: Entity_lookup taxonomy_term restricted by VID

2 files
+ 44
1
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -10,6 +10,7 @@ use Drupal\migrate\MigrateExecutableInterface;
@@ -10,6 +10,7 @@ use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
use Drupal\migrate\Row;
 
use Masterminds\HTML5;
/**
/**
* Handles string to DOM and back conversions.
* Handles string to DOM and back conversions.
@@ -30,6 +31,9 @@ use Drupal\migrate\Row;
@@ -30,6 +31,9 @@ use Drupal\migrate\Row;
* declaration. Defaults to '1.0'.
* declaration. Defaults to '1.0'.
* - encoding: (optional) The encoding of the document as part of the XML
* - encoding: (optional) The encoding of the document as part of the XML
* declaration. Defaults to 'UTF-8'.
* declaration. Defaults to 'UTF-8'.
 
* - import_method: (optional) What parser to use. Possible values:
 
* - 'html': (default) use dom extension parsing.
 
* - 'html5': use html5 parsing.
*
*
* @codingStandardsIgnoreStart
* @codingStandardsIgnoreStart
*
*
@@ -95,6 +99,10 @@ class Dom extends ProcessPluginBase {
@@ -95,6 +99,10 @@ class Dom extends ProcessPluginBase {
if (!in_array($configuration['method'], ['import', 'export'])) {
if (!in_array($configuration['method'], ['import', 'export'])) {
throw new \InvalidArgumentException('The "method" must be "import" or "export".');
throw new \InvalidArgumentException('The "method" must be "import" or "export".');
}
}
 
$configuration['import_method'] = $configuration['import_method'] ?? 'html';
 
if (!in_array($configuration['import_method'], ['html', 'html5'])) {
 
throw new \InvalidArgumentException('The "import_method" must be "html" or "html5".');
 
}
parent::__construct($configuration, $plugin_id, $plugin_definition);
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->configuration += $this->defaultValues();
$this->configuration += $this->defaultValues();
$this->logMessages = (bool) $this->configuration['log_messages'];
$this->logMessages = (bool) $this->configuration['log_messages'];
@@ -159,7 +167,19 @@ class Dom extends ProcessPluginBase {
@@ -159,7 +167,19 @@ class Dom extends ProcessPluginBase {
}
}
$document = new \DOMDocument($this->configuration['version'], $this->configuration['encoding']);
$document = new \DOMDocument($this->configuration['version'], $this->configuration['encoding']);
$document->loadHTML($html);
switch ($this->configuration['import_method']) {
 
case 'html5':
 
$html5 = new HTML5([
 
'target_document' => $document,
 
'disable_html_ns' => TRUE,
 
]);
 
$html5->loadHTML($html);
 
break;
 
 
case 'html':
 
default:
 
$document->loadHTML($html);
 
}
if ($this->logMessages) {
if ($this->logMessages) {
restore_error_handler();
restore_error_handler();
Loading