You are here

class FormConverterFactory in Drupal 7 to 8/9 Module Upgrader 8

Hierarchy

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'
drupalmoduleupgrader.services.yml in ./drupalmoduleupgrader.services.yml
drupalmoduleupgrader.services.yml
1 service uses FormConverterFactory
drupalmoduleupgrader.form_converter in ./drupalmoduleupgrader.services.yml
Drupal\drupalmoduleupgrader\Utility\FormConverterFactory

File

src/Utility/FormConverterFactory.php, line 10

Namespace

Drupal\drupalmoduleupgrader\Utility
View 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

Namesort descending Modifiers Type Description Overrides
FormConverterFactory::$rewriter protected property
FormConverterFactory::get public function Creates a FormConverter for a specific form.
FormConverterFactory::__construct public function
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
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.