public static function FileMetadataCaching::processCaching in File metadata manager 8.2
Same name and namespace in other branches
- 8 src/Element/FileMetadataCaching.php \Drupal\file_mdm\Element\FileMetadataCaching::processCaching()
Processes a 'file_mdm_caching' form element.
Parameters
array $element: The form element to process.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
array $complete_form: The complete form structure.
Return value
array The processed element.
File
- src/
Element/ FileMetadataCaching.php, line 62
Class
- FileMetadataCaching
- Implements a form element to enable capturing cache information for file_mdm.
Namespace
Drupal\file_mdm\ElementCode
public static function processCaching(array &$element, FormStateInterface $form_state, array &$complete_form) {
$element['enabled'] = [
'#type' => 'checkbox',
'#title' => t('Cache metadata'),
'#default_value' => $element['#default_value']['enabled'],
'#description' => t("If selected, metadata retrieved from files will be cached for further access."),
];
$options = [
86400,
172800,
604800,
1209600,
3024000,
7862400,
];
$options = array_map([
\Drupal::service('date.formatter'),
'formatInterval',
], array_combine($options, $options));
$options = [
-1 => t('Never'),
] + $options;
$element['expiration'] = [
'#type' => 'select',
'#title' => t('Cache expires'),
'#default_value' => $element['#default_value']['expiration'],
'#options' => $options,
'#description' => t("Specify the required lifetime of cached entries. Longer times may lead to increased cache sizes."),
'#states' => [
'visible' => [
':input[name="' . $element['#name'] . '[enabled]"]' => [
'checked' => TRUE,
],
],
],
];
$element['disallowed_paths'] = [
'#type' => 'textarea',
'#title' => t('Excluded paths'),
'#rows' => 3,
'#default_value' => implode("\n", $element['#default_value']['disallowed_paths']),
'#description' => t("Only files prefixed by a valid URI scheme will be cached, like for example <kbd>public://</kbd>. Files in the <kbd>temporary://</kbd> scheme will never be cached. Specify here if there are any paths to be additionally <strong>excluded</strong> from caching, one per line. Use wildcard patterns when entering the path. For example, <kbd>public://styles/*</kbd>."),
'#states' => [
'visible' => [
':input[name="' . $element['#name'] . '[enabled]"]' => [
'checked' => TRUE,
],
],
],
];
return $element;
}