class TranslatableStringFactory

Creates translatable strings that can interoperate with Composer Stager.

@internal This is an internal part of Package Manager and may be changed or removed at any time without warning. External code should not interact with this class.

Hierarchy

Expanded class hierarchy of TranslatableStringFactory

2 files declare their use of TranslatableStringFactory
ServicesTest.php in core/modules/package_manager/tests/src/Kernel/ServicesTest.php
TranslatableStringTest.php in core/modules/package_manager/tests/src/Kernel/TranslatableStringTest.php

File

core/modules/package_manager/src/TranslatableStringFactory.php, line 21

Namespace

Drupal\package_manager
View source
final class TranslatableStringFactory implements TranslatableFactoryInterface {
    public function __construct(TranslatableFactoryInterface $decorated, TranslationInterface $translation) {
    }
    
    /**
     * {@inheritdoc}
     */
    public function createDomainOptions() : DomainOptionsInterface {
        return $this->decorated
            ->createDomainOptions();
    }
    
    /**
     * {@inheritdoc}
     */
    public function createTranslatableMessage(string $message, ?TranslationParametersInterface $parameters = NULL, ?string $domain = NULL) : TranslatableInterface {
        return new TranslatableStringAdapter($message, $parameters?->getAll() ?? [], [
            'context' => $domain ?? '',
        ], $this->translation);
    }
    
    /**
     * {@inheritdoc}
     */
    public function createTranslationParameters(array $parameters = []) : TranslationParametersInterface {
        return $this->decorated
            ->createTranslationParameters($parameters);
    }

}

Members


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