class FeedsYouTubeFetcherForm in Feeds: YouTube Parser 8
The configuration form for YouTube fetchers.
Hierarchy
- class \Drupal\feeds\Plugin\Type\ExternalPluginFormBase implements PluginFormInterface, PluginAwareInterface uses DependencySerializationTrait, StringTranslationTrait
- class \Drupal\feeds_youtube\Feeds\Fetcher\Form\FeedsYouTubeFetcherForm
Expanded class hierarchy of FeedsYouTubeFetcherForm
File
- src/
Feeds/ Fetcher/ Form/ FeedsYouTubeFetcherForm.php, line 11
Namespace
Drupal\feeds_youtube\Feeds\Fetcher\FormView source
class FeedsYouTubeFetcherForm extends ExternalPluginFormBase {
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$config = $this->plugin
->getConfiguration();
$form['google_developer_key'] = [
'#type' => 'textfield',
'#title' => $this
->t('API key'),
'#description' => $this
->t('Google API Key'),
'#default_value' => $config['google_developer_key'],
'#required' => TRUE,
];
$form['google_oauth_client_id'] = [
'#type' => 'textfield',
'#title' => $this
->t('Client ID'),
'#description' => $this
->t('Google OAuth 2.0 Client ID'),
'#default_value' => $config['google_oauth_client_id'],
'#required' => TRUE,
];
$form['google_oauth_client_secret'] = [
'#type' => 'textfield',
'#title' => $this
->t('Client secret'),
'#description' => $this
->t('Google OAuth 2.0 Client secret'),
'#default_value' => $config['google_oauth_client_secret'],
'#required' => TRUE,
];
$form['import_video_limit'] = array(
'#type' => 'number',
'#min' => 1,
'#title' => t('Limit the total number of imported videos'),
'#description' => t('Specify a limit for the total number of videos to import from YouTube.'),
'#default_value' => $config['import_video_limit'],
'#required' => TRUE,
);
$form['results_per_page'] = array(
'#type' => 'number',
'#min' => 1,
'#max' => 50,
'#title' => $this
->t('Limit videos per API request'),
'#description' => $this
->t('Limit the number of retrieved videos per API request.'),
'#default_value' => $config['results_per_page'],
'#required' => TRUE,
);
return $form;
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
// Trim all values before saving.
$values = $form_state
->getValues();
foreach ($values as &$value) {
if (is_string($value)) {
$value = trim($value);
}
}
$this->plugin
->setConfiguration($values);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
ExternalPluginFormBase:: |
protected | property | The Feeds plugin. | |
ExternalPluginFormBase:: |
public | function |
Sets the plugin for this object. Overrides PluginAwareInterface:: |
|
ExternalPluginFormBase:: |
public | function |
Form validation handler. Overrides PluginFormInterface:: |
5 |
FeedsYouTubeFetcherForm:: |
public | function |
Form constructor. Overrides PluginFormInterface:: |
|
FeedsYouTubeFetcherForm:: |
public | function |
Form submission handler. Overrides ExternalPluginFormBase:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |