class FormConverterFactory in Drupal 7 to 8/9 Module Upgrader 8
Hierarchy
- class \Drupal\drupalmoduleupgrader\Utility\FormConverterFactory uses StringTranslationTrait
Expanded class hierarchy of FormConverterFactory
1 file declares its use of FormConverterFactory
- FormRoute.php in src/
Plugin/ DMU/ Routing/ FormRoute.php
1 string reference to 'FormConverterFactory'
1 service uses FormConverterFactory
File
- src/
Utility/ FormConverterFactory.php, line 10
Namespace
Drupal\drupalmoduleupgrader\UtilityView source
class FormConverterFactory {
use StringTranslationTrait;
/**
* @var \Drupal\drupalmoduleupgrader\RewriterInterface
*/
protected $rewriter;
public function __construct(TranslationInterface $translator, PluginManagerInterface $rewriters) {
$this->stringTranslation = $translator;
$this->rewriter = $rewriters
->createInstance('form_state');
}
/**
* Creates a FormConverter for a specific form.
*
* @param \Drupal\drupalmoduleupgrader\TargetInterface $target
* The module which defines the form.
* @param string $form_id
* The original form ID.
*
* @return FormConverter
*
* @throws \BadMethodCallException if the target module doesn't define
* the given form.
*/
public function get(TargetInterface $target, $form_id) {
$indexer = $target
->getIndexer('function');
if ($indexer
->has($form_id)) {
return new FormConverter($target, $form_id, $this->rewriter);
}
else {
$message = $this
->t('@target does not define form @form_id.', [
'@target' => $target
->id(),
'@form_id' => $form_id,
]);
throw new \BadMethodCallException($message);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FormConverterFactory:: |
protected | property | ||
FormConverterFactory:: |
public | function | Creates a FormConverter for a specific form. | |
FormConverterFactory:: |
public | function | ||
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |