You are here

public function SourcePluginBase::count in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php \Drupal\migrate\Plugin\migrate\source\SourcePluginBase::count()
  2. 9 core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php \Drupal\migrate\Plugin\migrate\source\SourcePluginBase::count()
3 calls to SourcePluginBase::count()
CacheableEmbeddedDataSource::count in core/modules/migrate/tests/modules/migrate_cache_counts_test/src/Plugin/migrate/source/CacheableEmbeddedDataSource.php
ContentEntity::count in core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntity.php
Variable::initializeIterator in core/modules/migrate_drupal/src/Plugin/migrate/source/Variable.php
Initializes the iterator with the source data.
2 methods override SourcePluginBase::count()
ContentEntity::count in core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntity.php
EmbeddedDataSource::count in core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php

File

core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php, line 496

Class

SourcePluginBase
The base class for source plugins.

Namespace

Drupal\migrate\Plugin\migrate\source

Code

public function count($refresh = FALSE) {
  if ($this->skipCount) {
    return MigrateSourceInterface::NOT_COUNTABLE;
  }

  // Return the cached count if we are caching counts and a refresh is not
  // requested.
  if ($this->cacheCounts && !$refresh) {
    $cache_object = $this
      ->getCache()
      ->get($this->cacheKey, 'cache');
    if (is_object($cache_object)) {
      return $cache_object->data;
    }
  }
  $count = $this
    ->doCount();

  // Update the cache if we are caching counts.
  if ($this->cacheCounts) {
    $this
      ->getCache()
      ->set($this->cacheKey, $count);
  }
  return $count;
}