class FontFamily

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Theme/Plugin/DesignTokenValue/FontFamily.php \Drupal\Core\Theme\Plugin\DesignTokenValue\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));
  }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
AutowiredInstanceTrait::createInstanceAutowired public static function Instantiates a new instance of the implementing class using autowiring.
AutowiredInstanceTrait::getAutowireArguments private static function Resolves arguments for a method using autowiring.
ConfigurablePluginBase::__construct public function Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase::__construct 6
ConfigurableTrait::$configuration protected property Configuration information passed into the plugin.
ConfigurableTrait::getConfiguration public function Gets this plugin's configuration. 3
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 2
DependencySerializationTrait::__wakeup public function 2
DesignTokenValuePluginBase::prepareConfiguration public static function Prepares configuration for plugin creation. Overrides DesignTokenValueInterface::prepareConfiguration
FontFamily::$value protected property The array of font names (ordered from most to least preferred).
FontFamily::defaultConfiguration public function Gets default configuration for this plugin. Overrides ConfigurableTrait::defaultConfiguration
FontFamily::setConfiguration public function Sets the configuration for this plugin instance. Overrides ConfigurableTrait::setConfiguration
FontFamily::toCss public function Exports as CSS value. Overrides DesignTokenValueInterface::toCss
FontFamily::toDtcg public function Exports as DTCG. Overrides DesignTokenValueInterface::toDtcg
MessengerTrait::$messenger protected property The messenger. 27
MessengerTrait::messenger public function Gets the messenger. 27
MessengerTrait::setMessenger public function Sets the messenger.
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin ID.
PluginBase::create public static function Instantiates a new instance of the implementing class using autowiring. 70
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 2
PluginBase::getPluginId public function Gets the plugin ID of the plugin instance. Overrides PluginInspectionInterface::getPluginId
StringTranslationTrait::$stringTranslation protected property The string translation service. 3
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. 1

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