class FontFamily

Font family design token value.

Attributes

#[DesignTokenValue(id: 'fontFamily', label: new TranslatableMarkup('Font family'))]

Hierarchy

Expanded class hierarchy of FontFamily

5 files declare their use of FontFamily
DesignTokenPluginManagerTest.php in core/tests/Drupal/Tests/Core/Theme/DesignToken/DesignTokenPluginManagerTest.php
DesignTokenValuePluginManagerKernelTest.php in core/tests/Drupal/KernelTests/Core/Theme/DesignToken/DesignTokenValuePluginManagerKernelTest.php
FontFamilyTest.php in core/tests/Drupal/Tests/Core/Theme/DesignToken/Plugin/FontFamilyTest.php
GroupTest.php in core/tests/Drupal/Tests/Core/Theme/DesignToken/GroupTest.php
TypographyTest.php in core/tests/Drupal/Tests/Core/Theme/DesignToken/Plugin/TypographyTest.php
11 string references to 'FontFamily'
DesignTokenConfigEntityKernelTest::testConfigSchema in core/tests/Drupal/KernelTests/Core/Theme/DesignToken/DesignTokenConfigEntityKernelTest.php
Tests config schema.
DesignTokenConfigEntityKernelTest::testInvalidConfigSchema in core/tests/Drupal/KernelTests/Core/Theme/DesignToken/DesignTokenConfigEntityKernelTest.php
Tests invalid config schema.
DesignTokenPluginManagerKernelTest::testDetectedPlugins in core/tests/Drupal/KernelTests/Core/Theme/DesignToken/DesignTokenPluginManagerKernelTest.php
Tests that plugins can be provided by YAML files.
DesignTokenPluginManagerTest::getValuePlugins in core/tests/Drupal/Tests/Core/Theme/DesignToken/DesignTokenPluginManagerTest.php
Fake Design token value plugin instances.
DesignTokenPluginManagerTest::providerExtractDefinitions in core/tests/Drupal/Tests/Core/Theme/DesignToken/DesignTokenPluginManagerTest.php
Data provider for ::testExtractDefinitions().

... See full list

File

core/lib/Drupal/Core/Theme/Plugin/DesignTokenValue/FontFamily.php, line 15

Namespace

Drupal\Core\Theme\Plugin\DesignTokenValue
View source
class FontFamily extends DesignTokenValuePluginBase {
  
  /**
   * The array of font names (ordered from most to least preferred).
   */
  protected array $value;
  
  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() : array {
    return [
      'value' => [],
    ] + parent::defaultConfiguration();
  }
  
  /**
   * {@inheritdoc}
   */
  public function setConfiguration(array $configuration) : static {
    parent::setConfiguration($configuration);
    if (is_array($this->configuration['value'])) {
      $this->value = $this->configuration['value'];
    }
    elseif (is_string($this->configuration['value'])) {
      $this->value = [
        $this->configuration['value'],
      ];
    }
    return $this;
  }
  
  /**
   * {@inheritdoc}
   */
  public function toDtcg() : mixed {
    return $this->value;
  }
  
  /**
   * {@inheritdoc}
   */
  public function toCss() : string {
    return implode(', ', array_map(Html::escape(...), $this->value));
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.