You are here

public function Variable::count in Drupal 9

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

Gets the source count.

Return a count of available source records, from the cache if appropriate. Returns MigrateSourceInterface::NOT_COUNTABLE if the source is not countable.

Parameters

bool $refresh: (optional) Whether or not to refresh the count. Defaults to FALSE. Not all implementations support the reset flag. In such instances this parameter is ignored and the result of calling the method will always be up to date.

Return value

int The count.

Overrides SourcePluginBase::count

1 call to Variable::count()
Variable::initializeIterator in core/modules/migrate_drupal/src/Plugin/migrate/source/Variable.php
Initializes the iterator with the source data.
1 method overrides Variable::count()
SearchPage::count in core/modules/search/src/Plugin/migrate/source/d7/SearchPage.php
Gets the source count.

File

core/modules/migrate_drupal/src/Plugin/migrate/source/Variable.php, line 137

Class

Variable
Drupal variable source from database.

Namespace

Drupal\migrate_drupal\Plugin\migrate\source

Code

public function count($refresh = FALSE) {
  if (empty($this->variablesNoRowIfMissing)) {
    return 1;
  }
  $variable_names = array_keys($this
    ->query()
    ->execute()
    ->fetchAllAssoc('name'));
  if (!empty(array_diff($this->variablesNoRowIfMissing, $variable_names))) {
    return 0;
  }
  return 1;
}