Action.php in Drupal 9
File
core/modules/action/src/Plugin/migrate/source/Action.php
View source
<?php
namespace Drupal\action\Plugin\migrate\source;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
use Drupal\migrate\Row;
class Action extends DrupalSqlBase {
public function query() {
return $this
->select('actions', 'a')
->fields('a');
}
public function fields() {
$fields = [
'aid' => $this
->t('Action ID'),
'type' => $this
->t('Module'),
'callback' => $this
->t('Callback function'),
'parameters' => $this
->t('Action configuration'),
];
if ($this
->getModuleSchemaVersion('system') >= 7000) {
$fields['label'] = $this
->t('Label of the action');
}
else {
$fields['description'] = $this
->t('Action description');
}
return $fields;
}
public function getIds() {
$ids['aid']['type'] = 'string';
return $ids;
}
public function prepareRow(Row $row) {
$aid = $row
->getSourceProperty('aid');
if (is_numeric($aid)) {
if ($this
->getModuleSchemaVersion('system') >= 7000) {
$label = $row
->getSourceProperty('label');
}
else {
$label = $row
->getSourceProperty('description');
}
$row
->setSourceProperty('aid', $label);
}
return parent::prepareRow($row);
}
}
Classes
Name |
Description |
Action |
Drupal 6/7 action source from database. |