public function FeedsDrushCommands::disableFeed in Feeds 8.3
Disable a feed specified by its id.
@command feeds:disable @aliases feeds-dis @usage feeds:disable 1
Parameters
int $fid: The id of the feed which should get disabled.
Throws
\Drupal\Core\Entity\EntityStorageException In case the feed could not be loaded.
File
- src/
Commands/ FeedsDrushCommands.php, line 148
Class
- FeedsDrushCommands
- Defines Drush commands for the Feeds module.
Namespace
Drupal\feeds\CommandsCode
public function disableFeed($fid = NULL) {
if (empty($fid)) {
throw new \Exception($this
->t('Please specify the ID of the feed you want to disable.'));
}
$feed = $this
->getFeed($fid);
// Check if the feed we got is valid.
if ($feed instanceof FeedInterface) {
if (!$feed
->isActive()) {
$this
->logger()
->notice($this
->t('This feed is already disabled.'));
return;
}
if (!$this
->io()
->confirm($this
->t('The following feed will be disabled: ":label" (id :id)', [
':label' => $feed
->label(),
':id' => $fid,
]))) {
throw new UserAbortException();
}
$feed
->setActive(FALSE);
$feed
->save();
$this->logger
->success($this
->t('The feed ":label" has been disabled.', [
':label' => $feed
->label(),
]));
}
else {
throw new \Exception($this
->t('There is no feed with id :id', [
':id' => $fid,
]));
}
}