public function SourcePluginBase::count in Drupal 9
Same name and namespace in other branches
- 8 core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php \Drupal\migrate\Plugin\migrate\source\SourcePluginBase::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.
2 calls to SourcePluginBase::count()
- CacheableEmbeddedDataSource::count in core/
modules/ migrate/ tests/ modules/ migrate_cache_counts_test/ src/ Plugin/ migrate/ source/ CacheableEmbeddedDataSource.php - Gets the source count.
- ContentEntity::count in core/
modules/ migrate_drupal/ src/ Plugin/ migrate/ source/ ContentEntity.php - Gets the source count.
9 methods override SourcePluginBase::count()
- ContentEntity::count in core/
modules/ migrate_drupal/ src/ Plugin/ migrate/ source/ ContentEntity.php - Gets the source count.
- EmbeddedDataSource::count in core/
modules/ migrate/ src/ Plugin/ migrate/ source/ EmbeddedDataSource.php - Gets the source count.
- EmptySource::count in core/
modules/ migrate/ src/ Plugin/ migrate/ source/ EmptySource.php - Gets the source count.
- EntityTranslationSettings::count in core/
modules/ content_translation/ src/ Plugin/ migrate/ source/ d7/ EntityTranslationSettings.php - Gets the source count.
- FieldInstance::count in core/
modules/ field/ src/ Plugin/ migrate/ source/ d7/ FieldInstance.php - Gets the source count.
File
- core/
modules/ migrate/ src/ Plugin/ migrate/ source/ SourcePluginBase.php, line 489
Class
- SourcePluginBase
- The base class for source plugins.
Namespace
Drupal\migrate\Plugin\migrate\sourceCode
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;
}