FilterFormatPermission.php in Drupal 10
File
core/modules/filter/src/Plugin/migrate/process/d6/FilterFormatPermission.php
View source
<?php
namespace Drupal\filter\Plugin\migrate\process\d6;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\MigrateLookupInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
use Symfony\Component\DependencyInjection\ContainerInterface;
class FilterFormatPermission extends ProcessPluginBase implements ContainerFactoryPluginInterface {
protected $migrateLookup;
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, MigrateLookupInterface $migrate_lookup) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->migration = $migration;
$this->migrateLookup = $migrate_lookup;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
return new static($configuration, $plugin_id, $plugin_definition, $migration, $container
->get('migrate.lookup'));
}
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
$rid = $row
->getSourceProperty('rid');
$migration = $this->configuration['migration'] ?? 'd6_filter_format';
if ($formats = $row
->getSourceProperty("filter_permissions:{$rid}")) {
foreach ($formats as $format) {
$lookup_result = $this->migrateLookup
->lookup($migration, [
$format,
]);
if ($lookup_result) {
$value[] = 'use text format ' . $lookup_result[0]['format'];
}
}
}
return $value;
}
}