public function SettingsForm::buildForm in Instagram Feeds 8
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides ConfigFormBase::buildForm
File
- src/
Form/ SettingsForm.php, line 40
Class
- SettingsForm
- Defines an Instagram Feeds configuration form.
Namespace
Drupal\instagram_feeds\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config(self::SETTINGS);
$base_field = [
'#type' => 'textfield',
'#required' => TRUE,
];
$form['client_id'] = [
'#title' => $this
->t('Instagram App (Client) ID'),
'#default_value' => $config
->get('client_id'),
] + $base_field;
$form['client_secret'] = [
'#title' => $this
->t('Instagram App (Client) Secret'),
'#default_value' => $config
->get('client_secret'),
'#description' => $this
->t('You may want to setup this via settings.php, that\'s why it is not required here.'),
'#required' => FALSE,
] + $base_field;
$form['refresh_frequency'] = [
'#type' => 'select',
'#options' => $this
->getRefreshFrequencyOptions(),
'#title' => $this
->t('Long-Lived Token Refresh Frequency'),
'#description' => $this
->t('The long-lived token is valid only 60 days. After it was expired it is no longer possible to refresh it. Also it cannot be refreshed more often than once per 24 hours.'),
'#field_prefix' => $this
->t('Refresh every'),
'#field_suffix' => $this
->t('by Cron'),
'#default_value' => $config
->get('refresh_frequency'),
];
$scheme_options = \Drupal::service('stream_wrapper_manager')
->getNames(StreamWrapperInterface::WRITE_VISIBLE);
$form['avatar_uri_scheme'] = [
'#type' => 'radios',
'#title' => t('Avatar upload destination'),
'#options' => $scheme_options,
'#default_value' => $config
->get('avatar_uri_scheme'),
'#description' => t('Select where the final files should be stored. Private file storage has significantly more overhead than public files, but allows restricted access to files within this field.'),
] + $base_field;
$form['avatar_directory'] = [
'#title' => $this
->t('Avatar directory'),
'#description' => $this
->t('Where to store avatars, for example: "instagram_avatars".'),
'#default_value' => $config
->get('avatar_directory'),
'#element_validate' => [
'\\Drupal\\file\\Plugin\\Field\\FieldType\\FileItem::validateDirectory',
],
] + $base_field + $this
->getTokenDescription();
$form['mapping'] = $this
->buildMappingForm($form, $form_state, 'mapping');
return parent::buildForm($form, $form_state);
}