function DrupalSqlBase::variableGet

Same name in other branches
  1. 8.9.x core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase::variableGet()
  2. 10 core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase::variableGet()
  3. 11.x 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 163

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;
}

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