theme_settings_convert_to_config example

    if (!empty($values['logo_path'])) {
      $values['logo_path'] = $this->validatePath($values['logo_path']);
    }
    if (!empty($values['favicon_path'])) {
      $values['favicon_path'] = $this->validatePath($values['favicon_path']);
    }

    if (empty($values['default_favicon']) && !empty($values['favicon_path'])) {
      $values['favicon_mimetype'] = $this->mimeTypeGuesser->guessMimeType($values['favicon_path']);
    }

    theme_settings_convert_to_config($values$config)->save();
  }

  /** * Helper function for the system_theme_settings form. * * Attempts to validate normal system paths, paths relative to the public files * directory, or stream wrapper URIs. If the given path is any of the above, * returns a valid path or URI that the theme system can display. * * @param string $path * A path relative to the Drupal root or to the public files directory, or * a stream wrapper URI. * * @return mixed * A valid path that can be displayed through the theme system, or FALSE if * the path could not be validated. */
// Tests default behavior.     $expected = '/' . $theme->getPath() . '/logo.svg';
    $this->assertEquals($expectedtheme_get_setting('logo.url', 'stark'));

    $config = $this->config('stark.settings');
    drupal_static_reset('theme_get_setting');

    $values = [
      'default_logo' => FALSE,
      'logo_path' => 'public://logo_with_scheme.png',
    ];
    theme_settings_convert_to_config($values$config)->save();

    // Tests logo path with scheme.     /** @var \Drupal\Core\File\FileUrlGeneratorInterface $file_url_generator */
    $file_url_generator = \Drupal::service('file_url_generator');
    $expected = $file_url_generator->generateString('public://logo_with_scheme.png');
    $this->assertEquals($expectedtheme_get_setting('logo.url', 'stark'));

    $values = [
      'default_logo' => FALSE,
      'logo_path' => $theme->getPath() . '/logo_relative_path.gif',
    ];
    

  public function import(Row $row, array $old_destination_id_values = []) {
    $imported = FALSE;
    $config = $this->configFactory->getEditable($row->getDestinationProperty('configuration_name'));
    $theme_settings = $row->getDestination();
    // Remove keys not in theme settings.     unset($theme_settings['configuration_name']);
    unset($theme_settings['theme_name']);
    unset($theme_settings['legacy_theme_name']);
    if (isset($theme_settings)) {
      theme_settings_convert_to_config($theme_settings$config);
      $config->save();
      $imported = TRUE;
    }
    return $imported;
  }

  /** * {@inheritdoc} */
  public function getIds() {
    $ids['name']['type'] = 'string';
    
Home | Imprint | This part of the site doesn't use cookies.