You are here

class ForumAccess in Forum Access 8

Same name in this branch
  1. 8 forum_access_migrate/src/Plugin/migrate/source/ForumAccess.php \Drupal\forum_access_migrate\Plugin\migrate\source\ForumAccess
  2. 8 forum_access_migrate/src/Plugin/migrate/destination/ForumAccess.php \Drupal\forum_access_migrate\Plugin\migrate\destination\ForumAccess

Provides table destination plugin.

Use this plugin for a table not registered with Drupal Schema API.

Plugin annotation


@MigrateDestination(
  id = "forum_access",
  destination_module = "forum_access"
)

Hierarchy

  • class \Drupal\forum_access_migrate\Plugin\migrate\destination\ForumAccess extends \Drupal\migrate_plus\Plugin\migrate\destination\Table

Expanded class hierarchy of ForumAccess

File

forum_access_migrate/src/Plugin/migrate/destination/ForumAccess.php, line 22

Namespace

Drupal\forum_access_migrate\Plugin\migrate\destination
View source
class ForumAccess extends Table {

  /**
   * The name of the destination table.
   *
   * @var string
   */
  protected $tableName;

  /**
   * IDMap compatible array of id fields.
   *
   * @var array
   */
  protected $idFields;

  /**
   * Array of fields present on the destination table.
   *
   * @var array
   */
  protected $fields;

  /**
   * The database connection.
   *
   * @var \Drupal\Core\Database\Connection
   */
  protected $dbConnection;

  /**
   * {@inheritdoc}
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, Connection $connection) {
    parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $connection);
    $this->dbConnection = $connection;
    $this->tableName = 'forum_access';
    $this->idFields = [
      'tid' => [
        'type' => 'integer',
      ],
      'rid' => [
        'type' => 'string',
      ],
    ];
    $this->fields = [];
    $this->supportsRollback = TRUE;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
    $db_key = !empty($configuration['database_key']) ? $configuration['database_key'] : NULL;
    return new static($configuration, $plugin_id, $plugin_definition, $migration, Database::getConnection('default', $db_key));
  }

  /**
   * {@inheritdoc}
   */
  public function import(Row $row, array $old_destination_id_values = []) {

    // Migrate moderators.
    module_load_include('inc', 'forum_access', 'includes/forum_access.acl');
    $tid = $row
      ->getSourceProperty('tid');
    $moderators = $row
      ->getSourceProperty('moderators');
    if (!empty($moderators)) {
      $acl_id = forum_access_get_acl($tid, 'moderate');
      foreach ($moderators as $uid) {
        acl_add_user($acl_id, $uid);
      }
    }
    return parent::import($row, $old_destination_id_values);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ForumAccess::$dbConnection protected property The database connection.
ForumAccess::$fields protected property Array of fields present on the destination table.
ForumAccess::$idFields protected property IDMap compatible array of id fields.
ForumAccess::$tableName protected property The name of the destination table.
ForumAccess::create public static function
ForumAccess::import public function
ForumAccess::__construct public function