blacksmith-8.x-1.x-dev/blacksmith.module
blacksmith.module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | <?php /* @noinspection PhpDocSignatureInspection */ /* @noinspection PhpUnused */ /* @noinspection PhpUnusedParameterInspection */ /** * @file * Module file for the Blacksmith module. */ use Drupal\Core\Form\FormStateInterface; /** * Implements hook_form_FORM_ID_alter() for system_file_system_settings(). * * Add interface translation directory setting to directories configuration. */ function blacksmith_form_system_file_system_settings_alter(& $form , FormStateInterface $form_state ) { $form [ 'blacksmith_source_path' ] = [ '#type' => 'textfield' , '#title' => t( 'Blacksmith source directory' ), '#default_value' => Drupal::configFactory()->getEditable( 'blacksmith.settings' )->get( 'source.path' ), '#maxlength' => 255, '#description' => t( 'A local file system path where blacksmith source files will be stored.' ), '#required' => TRUE, '#after_build' => [ 'system_check_directory' ], '#weight' => 20, ]; if ( $form [ 'file_default_scheme' ]) { $form [ 'file_default_scheme' ][ '#weight' ] = 30; } $form [ '#submit' ][] = 'blacksmith_system_file_system_settings_submit' ; } /** * Saves the content source config when the file system form is submitted. * * @inheritdoc */ function blacksmith_system_file_system_settings_submit(& $form , FormStateInterface $form_state ) { Drupal::configFactory()->getEditable( 'blacksmith.settings' ) ->set( 'source.path' , $form_state ->getValue( 'blacksmith_source_path' )) ->save(); } |