class DirectoryFetcherForm in Feeds 8.3
Defines a directory fetcher.
Hierarchy
- class \Drupal\feeds\Plugin\Type\ExternalPluginFormBase implements PluginFormInterface, PluginAwareInterface uses DependencySerializationTrait, StringTranslationTrait
- class \Drupal\feeds\Feeds\Fetcher\Form\DirectoryFetcherForm implements ContainerInjectionInterface
Expanded class hierarchy of DirectoryFetcherForm
1 file declares its use of DirectoryFetcherForm
- DirectoryFetcherFormTest.php in tests/
src/ Unit/ Feeds/ Fetcher/ Form/ DirectoryFetcherFormTest.php
File
- src/
Feeds/ Fetcher/ Form/ DirectoryFetcherForm.php, line 16
Namespace
Drupal\feeds\Feeds\Fetcher\FormView source
class DirectoryFetcherForm extends ExternalPluginFormBase implements ContainerInjectionInterface {
/**
* The stream wrapper manager.
*
* @var \Drupal\Core\StreamWrapper\StreamWrapperManager
*/
protected $streamWrapperManager;
/**
* Constructs a DirectoryFetcherForm object.
*
* @param \Drupal\Core\StreamWrapper\StreamWrapperManager $stream_wrapper_manager
* The stream wrapper manager.
*/
public function __construct(StreamWrapperManager $stream_wrapper_manager) {
$this->streamWrapperManager = $stream_wrapper_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('stream_wrapper_manager'));
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form['allowed_extensions'] = [
'#type' => 'textfield',
'#title' => $this
->t('Allowed file extensions'),
'#description' => $this
->t('Allowed file extensions for upload.'),
'#default_value' => $this->plugin
->getConfiguration('allowed_extensions'),
];
$form['allowed_schemes'] = [
'#type' => 'checkboxes',
'#title' => $this
->t('Allowed schemes'),
'#default_value' => $this->plugin
->getConfiguration('allowed_schemes'),
'#options' => $this
->getSchemeOptions(),
'#description' => $this
->t('Select the schemes you want to allow for direct upload.'),
];
$form['recursive_scan'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Search recursively'),
'#default_value' => $this->plugin
->getConfiguration('recursive_scan'),
'#description' => $this
->t('Search through sub-directories.'),
];
return $form;
}
/**
* {@inheritdoc}
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
$form_state
->setValue('allowed_schemes', array_filter($form_state
->getValue('allowed_schemes', [])));
$extensions = preg_replace('/\\s+/', ' ', trim($form_state
->getValue('allowed_extensions', '')));
$form_state
->setValue('allowed_extensions', $extensions);
}
/**
* Returns available scheme options for use in checkboxes or select list.
*
* @return array
* The available scheme array keyed scheme => description.
*/
protected function getSchemeOptions() {
$options = [];
foreach ($this->streamWrapperManager
->getDescriptions(StreamWrapperInterface::WRITE_VISIBLE) as $scheme => $description) {
$options[$scheme] = Html::escape($scheme . ': ' . $description);
}
return $options;
}
}
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 | |
DirectoryFetcherForm:: |
protected | property | The stream wrapper manager. | |
DirectoryFetcherForm:: |
public | function |
Form constructor. Overrides PluginFormInterface:: |
|
DirectoryFetcherForm:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
DirectoryFetcherForm:: |
protected | function | Returns available scheme options for use in checkboxes or select list. | |
DirectoryFetcherForm:: |
public | function |
Form validation handler. Overrides ExternalPluginFormBase:: |
|
DirectoryFetcherForm:: |
public | function | Constructs a DirectoryFetcherForm object. | |
ExternalPluginFormBase:: |
protected | property | The Feeds plugin. | |
ExternalPluginFormBase:: |
public | function |
Sets the plugin for this object. Overrides PluginAwareInterface:: |
|
ExternalPluginFormBase:: |
public | function |
Form submission handler. Overrides PluginFormInterface:: |
4 |
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. |