You are here

protected function DrupalSqlBase::variableGet in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase::variableGet()

Reads a variable from a source Drupal database.

Parameters

$name: Name of the variable.

$default: The default value.

Return value

mixed

33 calls to DrupalSqlBase::variableGet()
Block::initializeIterator in core/modules/block/src/Plugin/migrate/source/Block.php
Initializes the iterator with the source data.
Block::prepareRow in core/modules/block/src/Plugin/migrate/source/Block.php
Adds additional data to the row.
Comment::prepareComment in core/modules/comment/src/Plugin/migrate/source/d6/Comment.php
Provides a BC layer for deprecated sources.
Comment::prepareRow in core/modules/comment/src/Plugin/migrate/source/d6/Comment.php
Adds additional data to the row.
Comment::prepareRow in core/modules/comment/src/Plugin/migrate/source/d7/Comment.php
Adds additional data to the row.

... See full list

File

core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php, line 162

Class

DrupalSqlBase
A base class for source plugins using a Drupal database as a source.

Namespace

Drupal\migrate_drupal\Plugin\migrate\source

Code

protected function variableGet($name, $default) {
  try {
    $result = $this
      ->select('variable', 'v')
      ->fields('v', [
      'value',
    ])
      ->condition('name', $name)
      ->execute()
      ->fetchField();
  } catch (\Exception $e) {
    $result = FALSE;
  }
  return $result !== FALSE ? unserialize($result) : $default;
}