public function SourcePluginBase::count in Drupal 8
Same name and namespace in other branches
- 9 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 -1 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.
1 call to SourcePluginBase::count()
- ContentEntity::count in core/
modules/ migrate_drupal/ src/ Plugin/ migrate/ source/ ContentEntity.php - Gets the source count.
4 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.
- SqlBase::count in core/
modules/ migrate/ src/ Plugin/ migrate/ source/ SqlBase.php - Gets the source count.
File
- core/
modules/ migrate/ src/ Plugin/ migrate/ source/ SourcePluginBase.php, line 448
Class
- SourcePluginBase
- The base class for source plugins.
Namespace
Drupal\migrate\Plugin\migrate\sourceCode
public function count($refresh = FALSE) {
if ($this->skipCount) {
return -1;
}
if (!isset($this->cacheKey)) {
$this->cacheKey = hash('sha256', $this
->getPluginId());
}
// If a refresh is requested, or we're not caching counts, ask the derived
// class to get the count from the source.
if ($refresh || !$this->cacheCounts) {
$count = $this
->doCount();
$this
->getCache()
->set($this->cacheKey, $count);
}
else {
// Caching is in play, first try to retrieve a cached count.
$cache_object = $this
->getCache()
->get($this->cacheKey, 'cache');
if (is_object($cache_object)) {
// Success.
$count = $cache_object->data;
}
else {
// No cached count, ask the derived class to count 'em up, and cache
// the result.
$count = $this
->doCount();
$this
->getCache()
->set($this->cacheKey, $count);
}
}
return $count;
}