class GetId3ConfigForm in getID3() 8
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, LinkGeneratorTrait, RedirectDestinationTrait, UrlGeneratorTrait, StringTranslationTrait
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
- class \Drupal\getid3\Form\GetId3ConfigForm
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of GetId3ConfigForm
1 string reference to 'GetId3ConfigForm'
File
- src/
Form/ GetId3ConfigForm.php, line 14 - Contains \Drupal\getid3\Form\GetId3ConfigForm.
Namespace
Drupal\getid3\FormView source
class GetId3ConfigForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'getid3_systemconfigformbase';
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'getid3.settings',
];
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$path = getid3_get_path();
$form['getid3_path'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Path'),
'#default_value' => $path,
'#description' => $this
->t('The location where getID3() is installed. Relative paths are from the Drupal root directory.'),
);
$form['getid3_path']['#after_build'][] = array(
get_class($this),
'afterBuild',
);
if ($version = getid3_get_version()) {
$form['getid3_version'] = array(
'#type' => 'item',
'#title' => $this
->t('Version'),
'#markup' => '<pre>' . SafeMarkup::checkPlain($version) . '</pre>',
'#description' => $this
->t("If you're seeing this it indicates that the getID3 library was found."),
);
// Check for existence of the 'demos' folder, contained in the getID3
// library. The contents of this folder create a potential securtiy hole,
// so we recommend that the user delete it.
$getid3_demos_path = $path . '/../demos';
if (file_exists($getid3_demos_path)) {
drupal_set_message($this
->t("Your getID3 library is insecure! The demos distributed with getID3 contains code which creates a huge security hole. Remove the demos directory (%path) from beneath Drupal's directory.", array(
'%path' => realpath($getid3_demos_path),
)), 'error');
}
}
$show_warnings = $this
->config('getid3.settings')
->get('getid3_show_warnings');
if (empty($show_warnings)) {
$show_warnings = FALSE;
}
$form['getid3_show_warnings'] = array(
'#type' => 'checkbox',
'#title' => $this
->t("Display Warnings"),
'#default_value' => $show_warnings,
'#description' => $this
->t("Check this to display the warning messages from the getID3 library when reading and writing ID3 tags. Generally it's a good idea to leave this unchecked, getID3 reports warnings for several trivial problems and the warnings can be confusing to users. This setting can be useful when debugging problems with the ID3 tags."),
);
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
// Save the new value.
$this
->config('getid3.settings')
->set('path', $form_state
->getValue('getid3_path'))
->set('getid3_show_warnings', $form_state
->getValue('getid3_show_warnings'))
->save();
}
/**
* Verifies that getid3 is in the directory specified by the form element.
*
* Checks that the directory in $form_element exists and contains files named
* 'getid3.php' and 'write.php'. If validation fails, the form element is
* flagged with an error.
*
* @param array $form_element
* The form element containing the name of the directory to check.
*
* @param \Drupal\Core\Form\FormStateInterface $form_state
* @return array
*/
public static function afterBuild(array $form_element, FormStateInterface $form_state) {
$path = $form_state
->getValue('getid3_path');
if (!is_dir($path) || !(file_exists($path . '/getid3.php') && file_exists($path . '/write.php'))) {
drupal_set_message(t('The getID3 files <em>getid3.php</em> and <em>write.php</em> could not be found in the %path directory.', array(
'%path' => $path,
)), 'error');
}
return $form_element;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigFormBase:: |
public static | function |
Instantiates a new instance of this class. Overrides FormBase:: |
13 |
ConfigFormBase:: |
public | function | Constructs a \Drupal\system\ConfigFormBase object. | 11 |
ConfigFormBaseTrait:: |
protected | function | Retrieves a configuration object. | |
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 | |
FormBase:: |
protected | property | The config factory. | 1 |
FormBase:: |
protected | property | The request stack. | 1 |
FormBase:: |
protected | property | The route match. | |
FormBase:: |
protected | function | Gets the config factory for this form. | 1 |
FormBase:: |
private | function | Returns the service container. | |
FormBase:: |
protected | function | Gets the current user. | |
FormBase:: |
protected | function | Gets the request object. | |
FormBase:: |
protected | function | Gets the route match. | |
FormBase:: |
protected | function | Gets the logger for a specific channel. | |
FormBase:: |
protected | function |
Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait:: |
|
FormBase:: |
public | function | Resets the configuration factory. | |
FormBase:: |
public | function | Sets the config factory for this form. | |
FormBase:: |
public | function | Sets the request stack object to use. | |
GetId3ConfigForm:: |
public static | function | Verifies that getid3 is in the directory specified by the form element. | |
GetId3ConfigForm:: |
public | function |
Form constructor. Overrides ConfigFormBase:: |
|
GetId3ConfigForm:: |
protected | function |
Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait:: |
|
GetId3ConfigForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
GetId3ConfigForm:: |
public | function |
Form submission handler. Overrides ConfigFormBase:: |
|
GetId3ConfigForm:: |
public | function |
Form validation handler. Overrides FormBase:: |
|
LinkGeneratorTrait:: |
protected | property | The link generator. | 1 |
LinkGeneratorTrait:: |
protected | function | Returns the link generator. | |
LinkGeneratorTrait:: |
protected | function | Renders a link to a route given a route name and its parameters. | |
LinkGeneratorTrait:: |
public | function | Sets the link generator service. | |
LoggerChannelTrait:: |
protected | property | The logger channel factory service. | |
LoggerChannelTrait:: |
protected | function | Gets the logger for a specific channel. | |
LoggerChannelTrait:: |
public | function | Injects the logger channel factory. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
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. | |
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. |