
| Current Path : /var/www/html1/bbp/web/modules/contrib/migrate_plus/src/Plugin/migrate/process/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html1/bbp/web/modules/contrib/migrate_plus/src/Plugin/migrate/process/DomProcessBase.php |
<?php
namespace Drupal\migrate_plus\Plugin\migrate\process;
use Drupal\migrate\MigrateSkipRowException;
use Drupal\migrate\ProcessPluginBase;
/**
* Base class for process plugins that work with \DOMDocument objects.
*
* Use Dom::import() to convert a string to a \DOMDocument object, then plugins
* derived from this class to manipulate the object, then Dom::export() to
* convert back to a string.
*/
abstract class DomProcessBase extends ProcessPluginBase {
/**
* Document to use.
*
* @var \DOMDocument
*/
protected $document;
/**
* Xpath query object.
*
* @var \DOMXPath
*/
protected $xpath;
/**
* Initialize the class properties.
*
* @param mixed $value
* Process plugin value.
* @param string $destination_property
* The name of the destination being processed. Used to generate an error
* message.
*
* @throws \Drupal\migrate\MigrateSkipRowException
* If $value is not a \DOMDocument object.
*/
protected function init($value, $destination_property) {
if (!($value instanceof \DOMDocument)) {
$message = sprintf(
'The %s plugin in the %s process pipeline requires a \DOMDocument object. You can use the dom plugin to convert a string to \DOMDocument.',
$this->getPluginId(),
$destination_property
);
throw new MigrateSkipRowException($message);
}
$this->document = $value;
$this->xpath = new \DOMXPath($this->document);
}
}