blacksmith-8.x-1.x-dev/blacksmith.module

blacksmith.module
<?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();
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc