class FileSystemForm

Configure file system settings for this site.

Hierarchy

Expanded class hierarchy of FileSystemForm

1 string reference to 'FileSystemForm'
system.routing.yml in drupal/core/modules/system/system.routing.yml
drupal/core/modules/system/system.routing.yml

File

drupal/core/modules/system/lib/Drupal/system/Form/FileSystemForm.php, line 15
Contains \Drupal\system\Form\FileSystemForm.

Namespace

Drupal\system\Form
View source
class FileSystemForm extends SystemConfigFormBase {

  /**
   * {@inheritdoc}
   */
  public function getFormID() {
    return 'system_file_system_settings';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, array &$form_state) {
    $config = $this->configFactory
      ->get('system.file');
    $form['file_public_path'] = array(
      '#type' => 'textfield',
      '#title' => t('Public file system path'),
      '#default_value' => variable_get('file_public_path', conf_path() . '/files'),
      '#maxlength' => 255,
      '#description' => t('A local file system path where public files will be stored. This directory must exist and be writable by Drupal. This directory must be relative to the Drupal installation directory and be accessible over the web.'),
      '#after_build' => array(
        'system_check_directory',
      ),
    );
    $form['file_private_path'] = array(
      '#type' => 'textfield',
      '#title' => t('Private file system path'),
      '#default_value' => $config
        ->get('path.private'),
      '#maxlength' => 255,
      '#description' => t('An existing local file system path for storing private files. It should be writable by Drupal and not accessible over the web. See the online handbook for <a href="@handbook">more information about securing private files</a>.', array(
        '@handbook' => 'http://drupal.org/documentation/modules/file',
      )),
      '#after_build' => array(
        'system_check_directory',
      ),
    );
    $form['file_temporary_path'] = array(
      '#type' => 'textfield',
      '#title' => t('Temporary directory'),
      '#default_value' => $config
        ->get('path.temporary'),
      '#maxlength' => 255,
      '#description' => t('A local file system path where temporary files will be stored. This directory should not be accessible over the web.'),
      '#after_build' => array(
        'system_check_directory',
      ),
    );

    // Any visible, writeable wrapper can potentially be used for the files
    // directory, including a remote file system that integrates with a CDN.
    foreach (file_get_stream_wrappers(STREAM_WRAPPERS_WRITE_VISIBLE) as $scheme => $info) {
      $options[$scheme] = check_plain($info['description']);
    }
    if (!empty($options)) {
      $form['file_default_scheme'] = array(
        '#type' => 'radios',
        '#title' => t('Default download method'),
        '#default_value' => $config
          ->get('default_scheme'),
        '#options' => $options,
        '#description' => t('This setting is used as the preferred download method. The use of public files is more efficient, but does not provide any access control.'),
      );
    }
    return parent::buildForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, array &$form_state) {
    $config = $this->configFactory
      ->get('system.file')
      ->set('path.private', $form_state['values']['file_private_path'])
      ->set('path.temporary', $form_state['values']['file_temporary_path']);
    variable_set('file_public_path', $form_state['values']['file_public_path']);
    if (isset($form_state['values']['file_default_scheme'])) {
      $config
        ->set('default_scheme', $form_state['values']['file_default_scheme']);
    }
    $config
      ->save();
    parent::submitForm($form, $form_state);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FileSystemForm::buildForm public function Implements \Drupal\Core\Form\FormInterface::buildForm(). Overrides SystemConfigFormBase::buildForm
FileSystemForm::getFormID public function Returns a unique string identifying the form. Overrides FormInterface::getFormID
FileSystemForm::submitForm public function Implements \Drupal\Core\Form\FormInterface::submitForm(). Overrides SystemConfigFormBase::submitForm
SystemConfigFormBase::$configFactory protected property Stores the configuration factory.
SystemConfigFormBase::create public static function Instantiates a new instance of this controller. Overrides ControllerInterface::create 9
SystemConfigFormBase::validateForm public function Implements \Drupal\Core\Form\FormInterface::validateForm(). Overrides FormInterface::validateForm 7
SystemConfigFormBase::__construct public function Constructs a \Drupal\system\SystemConfigFormBase object. 9