public function Feed::lock in Feeds 8.3
Locks a feed.
Throws
\Drupal\feeds\Exception\LockException Thrown if the lock is unavailable.
Overrides FeedInterface::lock
File
- src/
Entity/ Feed.php, line 483
Class
- Feed
- Defines the feed entity class.
Namespace
Drupal\feeds\EntityCode
public function lock() {
if (!\Drupal::service('lock.persistent')
->acquire("feeds_feed_{$this->id()}", 3600 * 12)) {
$args = [
'@id' => $this
->bundle(),
'@fid' => $this
->id(),
];
throw new LockException(new FormattableMarkup('Cannot acquire lock for feed @id / @fid.', $args));
}
Cache::invalidateTags([
'feeds_feed_locked',
]);
}