class Action

Same name in this branch
  1. 9 core/modules/action/src/Plugin/migrate/source/Action.php \Drupal\action\Plugin\migrate\source\Action
  2. 9 core/modules/system/src/Entity/Action.php \Drupal\system\Entity\Action
  3. 9 core/lib/Drupal/Core/Annotation/Action.php \Drupal\Core\Annotation\Action
Same name and namespace in other branches
  1. 11.x core/modules/system/src/Entity/Action.php \Drupal\system\Entity\Action
  2. 11.x core/modules/system/src/Plugin/migrate/source/Action.php \Drupal\system\Plugin\migrate\source\Action
  3. 11.x core/lib/Drupal/Core/Action/Attribute/Action.php \Drupal\Core\Action\Attribute\Action
  4. 11.x core/lib/Drupal/Core/Annotation/Action.php \Drupal\Core\Annotation\Action

Drupal action source from database.

Plugin annotation


@MigrateSource(
  id = "action",
  source_module = "system"
)

Hierarchy

Expanded class hierarchy of Action

1 file declares its use of Action
Action.php in core/modules/action/src/Plugin/migrate/source/Action.php
33 string references to 'Action'
action.routing.yml in core/modules/action/action.routing.yml
core/modules/action/action.routing.yml
ActionAdminManageForm::buildForm in core/modules/action/src/Form/ActionAdminManageForm.php
ActionAdminManageForm::submitForm in core/modules/action/src/Form/ActionAdminManageForm.php
ActionFormBase::create in core/modules/action/src/Form/ActionFormBase.php
ActionListTest::testEmptyActionList in core/modules/action/tests/src/Functional/ActionListTest.php
Tests the behavior when there are no actions to list in the admin page.

... See full list

File

core/modules/system/src/Plugin/migrate/source/Action.php, line 16

Namespace

Drupal\system\Plugin\migrate\source
View source
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);
  }

}

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