feeds-8.x-3.0-alpha1/src/Form/FeedImportForm.php
src/Form/FeedImportForm.php
<?php
namespace Drupal\feeds\Form;
use Drupal\Core\Entity\ContentEntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Provides a form for importing a feed.
*/
class FeedImportForm extends ContentEntityConfirmFormBase {
/**
* {@inheritdoc}
*/
public function getQuestion() {
return $this->t('Are you sure you want to import the feed %feed?', ['%feed' => $this->entity->label()]);
}
/**
* {@inheritdoc}
*/
public function getCancelUrl() {
return $this->entity->toUrl();
}
/**
* {@inheritdoc}
*/
public function getConfirmText() {
return $this->t('Import');
}
/**
* {@inheritdoc}
*/
protected function actions(array $form, FormStateInterface $form_state) {
$actions = parent::actions($form, $form_state);
$actions['submit']['#disabled'] = $this->entity->isLocked();
return $actions;
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
// The import process will create its own messages.
$this->entity->startBatchImport();
$form_state->setRedirectUrl($this->getCancelUrl());
}
}
