Action.php

Same filename in this branch
  1. 10 core/modules/system/src/Entity/Action.php
  2. 10 core/lib/Drupal/Core/Action/Attribute/Action.php
  3. 10 core/lib/Drupal/Core/Annotation/Action.php
Same filename and directory in other branches
  1. 9 core/modules/action/src/Plugin/migrate/source/Action.php
  2. 9 core/modules/system/src/Entity/Action.php
  3. 9 core/modules/system/src/Plugin/migrate/source/Action.php
  4. 9 core/lib/Drupal/Core/Annotation/Action.php
  5. 8.9.x core/modules/action/src/Plugin/migrate/source/Action.php
  6. 8.9.x core/modules/system/src/Entity/Action.php
  7. 8.9.x core/lib/Drupal/Core/Annotation/Action.php
  8. 11.x core/modules/system/src/Entity/Action.php
  9. 11.x core/modules/system/src/Plugin/migrate/source/Action.php
  10. 11.x core/lib/Drupal/Core/Action/Attribute/Action.php
  11. 11.x core/lib/Drupal/Core/Annotation/Action.php

Namespace

Drupal\system\Plugin\migrate\source

File

core/modules/system/src/Plugin/migrate/source/Action.php

View source
<?php

namespace Drupal\system\Plugin\migrate\source;

use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
use Drupal\migrate\Row;

/**
 * Drupal action source from database.
 *
 * @MigrateSource(
 *   id = "action",
 *   source_module = "system"
 * )
 */
class Action extends DrupalSqlBase {
  
  /**
   * {@inheritdoc}
   */
  public function query() {
    return $this->select('actions', 'a')
      ->fields('a');
  }
  
  /**
   * {@inheritdoc}
   */
  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;
  }
  
  /**
   * {@inheritdoc}
   */
  public function getIds() {
    $ids['aid']['type'] = 'string';
    return $ids;
  }
  
  /**
   * {@inheritdoc}
   */
  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

Title Deprecated Summary
Action Drupal action source from database.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.