public static function FeedImport::deleteExpired in Feed Import 8
Delete all expired items.
Parameters
int $max: Max number of entity ids to delete from a hash manager
Return value
int Number of deleted entities
File
- feed_import_base/
src/ FeedImport.php, line 457
Class
- FeedImport
- This class provides helper functions for feed import.
Namespace
Drupal\feed_import_baseCode
public static function deleteExpired($max = 0) {
$deleted = 0;
foreach (static::loadAllFeeds() as $feed) {
if (empty($feed->settings['hashes']['class'])) {
continue;
}
$class = $feed->settings['hashes']['class'];
$items = $class::getExpired($feed->machine_name, $max);
foreach ($items as $e => &$ids) {
$entity = static::getEntityInfo($e);
// Delete entities.
if ($entity->deleteCallback) {
$f = $entity->deleteCallback . '_multiple';
if (function_exists($f)) {
$f($ids);
}
else {
array_map($entity->deleteCallback, $ids);
}
}
else {
$entity->controller
->delete($ids);
}
// Delete hashes.
$class::delete(array_keys($ids));
$deleted += count($ids);
unset($items[$e], $entity);
}
}
return $deleted;
}