FeedScheduleImportForm.php in Feeds 8.3
File
src/Form/FeedScheduleImportForm.php
View source
<?php
namespace Drupal\feeds\Form;
use Drupal\Core\Entity\ContentEntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
class FeedScheduleImportForm extends ContentEntityConfirmFormBase {
public function getQuestion() {
return $this
->t('Are you sure you want to schedule the import of the feed %feed?', [
'%feed' => $this->entity
->label(),
]);
}
public function getDescription() {
return $this
->t('The import will run during cron.') . ' ' . parent::getDescription();
}
public function getCancelUrl() {
return $this->entity
->toUrl();
}
public function getConfirmText() {
return $this
->t('Schedule import');
}
protected function actions(array $form, FormStateInterface $form_state) {
$actions = parent::actions($form, $form_state);
$actions['submit']['#disabled'] = $this->entity
->isLocked();
return $actions;
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity
->startCronImport();
$args = [
'@type' => $this->entity
->getType()
->label(),
'%title' => $this->entity
->label(),
];
$this
->logger('feeds')
->notice('@type: scheduled import for %title.', $args);
$this
->messenger()
->addStatus($this
->t('%title has been scheduled for import.', $args));
$form_state
->setRedirectUrl($this
->getCancelUrl());
}
}