You are here

class RoutePlannerSettingsForm in Route Planner 8

Hierarchy

Expanded class hierarchy of RoutePlannerSettingsForm

1 string reference to 'RoutePlannerSettingsForm'
route_planner.routing.yml in ./route_planner.routing.yml
route_planner.routing.yml

File

src/Form/RoutePlannerSettingsForm.php, line 9

Namespace

Drupal\route_planner\Form
View source
class RoutePlannerSettingsForm extends ConfigFormBase {

  /**
   * {@inheritdoc}.
   */
  public function getEditableConfigNames() {
    return [
      'route_planner.settings',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'route_planner_settings_form';
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $config = $this->configFactory
      ->getEditable('route_planner.settings');
    foreach (Element::children($form) as $fieldset) {
      foreach (Element::children($form[$fieldset]) as $variable) {
        $config
          ->set($variable, $form_state
          ->getValue($variable));
      }
    }
    $config
      ->save();
    parent::submitForm($form, $form_state);
  }
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form['route_planner'] = array(
      '#type' => 'fieldset',
      '#title' => $this
        ->t('Route Planner Settings'),
    );
    $form['route_planner']['route_planner_address'] = array(
      '#type' => 'textfield',
      '#description' => $this
        ->t('Your point of interesst or company address.'),
      '#title' => $this
        ->t('Target address'),
      '#default_value' => \Drupal::config('route_planner.settings')
        ->get('route_planner_address'),
    );
    $form['route_planner']['route_planner_address_end'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Show an end point field.'),
      '#description' => $this
        ->t('If checked the address block will have a end point field with the default address from your POI above.'),
      '#default_value' => \Drupal::config('route_planner.settings')
        ->get('route_planner_address_end'),
    );
    $form['route_planner']['route_planner_unitsystem'] = array(
      '#type' => 'select',
      '#description' => $this
        ->t('Select your preferred unit system IMPERIAL or METRIC.'),
      '#title' => $this
        ->t('Unit System'),
      '#options' => array(
        0 => t('metric'),
        1 => t('imperial'),
      ),
      '#default_value' => \Drupal::config('route_planner.settings')
        ->get('route_planner_unitsystem'),
    );

    // API settings
    $form['api-settings'] = array(
      '#type' => 'fieldset',
      '#title' => $this
        ->t('Google Maps JavaScript API Settings'),
    );
    $form['api-settings']['route_planner_api_key'] = array(
      '#type' => 'textfield',
      '#title' => $this
        ->t('Google Maps JavaScript API Key'),
      '#description' => $this
        ->t('Visit <a href="https://developers.google.com/maps/documentation/javascript/get-api-key">developers.google.com > Get Key</a> for details on how to get a key.'),
      '#default_value' => \Drupal::config('route_planner.settings')
        ->get('route_planner_api_key'),
    );
    $form['api-settings']['route_planner_api_language'] = array(
      '#type' => 'textfield',
      '#title' => $this
        ->t('Language Localization'),
      '#description' => $this
        ->t('Visit <a href="https://developers.google.com/maps/documentation/javascript/localization">developers.google.com > Maps Localization</a> for details.'),
      '#default_value' => \Drupal::config('route_planner.settings')
        ->get('route_planner_api_language'),
    );
    $form['map-settings'] = array(
      '#type' => 'fieldset',
      '#title' => $this
        ->t('Map Settings'),
    );
    $form['map-settings']['route_planner_map_height'] = array(
      '#type' => 'textfield',
      '#title' => $this
        ->t('Map Height'),
      '#description' => $this
        ->t('A fixed height for example 300px.'),
      '#size' => 10,
      '#default_value' => \Drupal::config('route_planner.settings')
        ->get('route_planner_map_height'),
    );
    $form['map-settings']['route_planner_map_width'] = array(
      '#type' => 'textfield',
      '#title' => $this
        ->t('Map Width'),
      '#description' => $this
        ->t('A width value in % or px, for example 300px or 100%.'),
      '#size' => 10,
      '#default_value' => \Drupal::config('route_planner.settings')
        ->get('route_planner_map_width'),
    );
    $form['map-settings']['route_planner_map_zoom'] = array(
      '#type' => 'textfield',
      '#title' => $this
        ->t('Zoom Level'),
      '#description' => $this
        ->t('A value between 1 and 100 (a normal value is around 10).'),
      '#size' => 10,
      '#default_value' => \Drupal::config('route_planner.settings')
        ->get('route_planner_map_zoom'),
    );
    $form['map-settings']['route_planner_map_defaultui'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Disable Default UI Controls'),
      '#description' => $this
        ->t('Disables all UI Controls in the map.'),
      '#default_value' => \Drupal::config('route_planner.settings')
        ->get('route_planner_map_defaultui'),
    );
    $form['map-settings']['route_planner_map_zoomcontrol'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Enable ZoomControl'),
      '#default_value' => \Drupal::config('route_planner.settings')
        ->get('route_planner_map_zoomcontrol'),
    );
    $form['map-settings']['route_planner_map_scrollwheel'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Enable ScrollWheel'),
      '#default_value' => \Drupal::config('route_planner.settings')
        ->get('route_planner_map_scrollwheel'),
    );
    $form['map-settings']['route_planner_map_maptypecontrol'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Enable Map Type Control'),
      '#default_value' => \Drupal::config('route_planner.settings')
        ->get('route_planner_map_maptypecontrol'),
    );
    $form['map-settings']['route_planner_map_scalecontrol'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Enable Scale Control'),
      '#default_value' => \Drupal::config('route_planner.settings')
        ->get('route_planner_map_scalecontrol'),
    );
    $form['map-settings']['route_planner_map_draggable'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Enable Mouse Drag'),
      '#default_value' => \Drupal::config('route_planner.settings')
        ->get('route_planner_map_draggable'),
    );
    $form['map-settings']['route_planner_map_doubbleclick'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Disable Doubble Click Zoom'),
      '#default_value' => \Drupal::config('route_planner.settings')
        ->get('route_planner_map_doubbleclick'),
    );
    $form['map-settings']['route_planner_map_streetviewcontrol'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Enable Streetview Control'),
      '#default_value' => \Drupal::config('route_planner.settings')
        ->get('route_planner_map_streetviewcontrol'),
    );
    $form['map-settings']['route_planner_map_overviewmapcontrol'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Enable Overview Map'),
      '#default_value' => \Drupal::config('route_planner.settings')
        ->get('route_planner_map_overviewmapcontrol'),
    );
    return parent::buildForm($form, $form_state);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigFormBase::create public static function Instantiates a new instance of this class. Overrides FormBase::create 13
ConfigFormBase::__construct public function Constructs a \Drupal\system\ConfigFormBase object. 11
ConfigFormBaseTrait::config protected function Retrieves a configuration object.
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
FormBase::$configFactory protected property The config factory. 1
FormBase::$requestStack protected property The request stack. 1
FormBase::$routeMatch protected property The route match.
FormBase::configFactory protected function Gets the config factory for this form. 1
FormBase::container private function Returns the service container.
FormBase::currentUser protected function Gets the current user.
FormBase::getRequest protected function Gets the request object.
FormBase::getRouteMatch protected function Gets the route match.
FormBase::logger protected function Gets the logger for a specific channel.
FormBase::redirect protected function Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait::redirect
FormBase::resetConfigFactory public function Resets the configuration factory.
FormBase::setConfigFactory public function Sets the config factory for this form.
FormBase::setRequestStack public function Sets the request stack object to use.
FormBase::validateForm public function Form validation handler. Overrides FormInterface::validateForm 62
LinkGeneratorTrait::$linkGenerator protected property The link generator. 1
LinkGeneratorTrait::getLinkGenerator Deprecated protected function Returns the link generator.
LinkGeneratorTrait::l Deprecated protected function Renders a link to a route given a route name and its parameters.
LinkGeneratorTrait::setLinkGenerator Deprecated public function Sets the link generator service.
LoggerChannelTrait::$loggerFactory protected property The logger channel factory service.
LoggerChannelTrait::getLogger protected function Gets the logger for a specific channel.
LoggerChannelTrait::setLoggerFactory public function Injects the logger channel factory.
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
RedirectDestinationTrait::$redirectDestination protected property The redirect destination service. 1
RedirectDestinationTrait::getDestinationArray protected function Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url.
RedirectDestinationTrait::getRedirectDestination protected function Returns the redirect destination service.
RedirectDestinationTrait::setRedirectDestination public function Sets the redirect destination service.
RoutePlannerSettingsForm::buildForm public function Form constructor. Overrides ConfigFormBase::buildForm
RoutePlannerSettingsForm::getEditableConfigNames public function . Overrides ConfigFormBaseTrait::getEditableConfigNames
RoutePlannerSettingsForm::getFormId public function Returns a unique string identifying the form. Overrides FormInterface::getFormId
RoutePlannerSettingsForm::submitForm public function Form submission handler. Overrides ConfigFormBase::submitForm
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
UrlGeneratorTrait::$urlGenerator protected property The url generator.
UrlGeneratorTrait::getUrlGenerator Deprecated protected function Returns the URL generator service.
UrlGeneratorTrait::setUrlGenerator Deprecated public function Sets the URL generator service.
UrlGeneratorTrait::url Deprecated protected function Generates a URL or path for a specific route based on the given parameters.