public function UploadFetcherFeedForm::submitConfigurationForm in Feeds 8.3
Form submission handler.
Parameters
array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().
Overrides ExternalPluginFormBase::submitConfigurationForm
File
- src/
Feeds/ Fetcher/ Form/ UploadFetcherFeedForm.php, line 91
Class
- UploadFetcherFeedForm
- Provides a form on the feed edit page for the UploadFetcher.
Namespace
Drupal\feeds\Feeds\Fetcher\FormCode
public function submitConfigurationForm(array &$form, FormStateInterface $form_state, FeedInterface $feed = NULL) {
// We need to store this for later so that we have the feed id.
$new_fid = reset($form_state
->getValue('source'));
$feed_config = $feed
->getConfigurationFor($this->plugin);
// Generate a UUID that maps to this feed for file usage. We can't depend
// on the feed id since this could be called before an id is assigned.
$feed_config['usage_id'] = $feed_config['usage_id'] ?: $this->uuid
->generate();
if ($new_fid != $feed_config['fid']) {
$this
->deleteFile($feed_config['fid'], $feed_config['usage_id']);
if ($new_fid) {
$file = $this->fileStorage
->load($new_fid);
$this->fileUsage
->add($file, 'feeds', $this->plugin
->pluginType(), $feed_config['usage_id']);
$file
->setPermanent();
$file
->save();
$feed_config['fid'] = $new_fid;
$feed
->setSource($file
->getFileUri());
}
}
$feed
->setConfigurationFor($this->plugin, $feed_config);
}