You are here

class LocalTaskItemForm in Translation Management Tool 8

Form controller for the localTaskItem edit forms.

Hierarchy

Expanded class hierarchy of LocalTaskItemForm

File

translators/tmgmt_local/src/Form/LocalTaskItemForm.php, line 23

Namespace

Drupal\tmgmt_local\Form
View source
class LocalTaskItemForm extends ContentEntityForm {

  /**
   * The task item.
   *
   * @var \Drupal\tmgmt_local\Entity\LocalTaskItem
   */
  protected $entity;

  /**
   * {@inheritdoc}
   */
  public function form(array $form, FormStateInterface $form_state) {
    $form = parent::form($form, $form_state);
    $task_item = $this->entity;
    $form['#title'] = $task_item
      ->label();
    $job_item = $task_item
      ->getJobItem();
    $job = $job_item
      ->getJob();
    $form['info'] = array(
      '#type' => 'container',
      '#attributes' => array(
        'class' => array(
          'tmgmt-local-task-info',
          'clearfix',
        ),
      ),
      '#weight' => 0,
    );
    $url = $job_item
      ->getSourceUrl();
    $form['info']['source'] = array(
      '#type' => 'item',
      '#title' => t('Source'),
      '#markup' => $url ? Link::fromTextAndUrl($job_item
        ->getSourceLabel(), $url)
        ->toString() : $job_item
        ->getSourceLabel(),
      '#prefix' => '<div class="tmgmt-ui-source tmgmt-ui-info-item">',
      '#suffix' => '</div>',
    );
    $form['info']['sourcetype'] = array(
      '#type' => 'item',
      '#title' => t('Source type'),
      '#markup' => $job_item
        ->getSourceType(),
      '#prefix' => '<div class="tmgmt-ui-source-type tmgmt-ui-info-item">',
      '#suffix' => '</div>',
    );
    $form['info']['source_language'] = array(
      '#type' => 'item',
      '#title' => t('Source language'),
      '#markup' => $job_item
        ->getJob()
        ->getSourceLanguage()
        ->getName(),
      '#prefix' => '<div class="tmgmt-ui-source-language tmgmt-ui-info-item">',
      '#suffix' => '</div>',
    );
    $form['info']['target_language'] = array(
      '#type' => 'item',
      '#title' => t('Target language'),
      '#markup' => $job_item
        ->getJob()
        ->getTargetLanguage()
        ->getName(),
      '#prefix' => '<div class="tmgmt-ui-target-language tmgmt-ui-info-item">',
      '#suffix' => '</div>',
    );
    $form['info']['changed'] = array(
      '#type' => 'item',
      '#title' => t('Last change'),
      '#value' => $task_item
        ->getChangedTime(),
      '#markup' => \Drupal::service('date.formatter')
        ->format($task_item
        ->getChangedTime()),
      '#prefix' => '<div class="tmgmt-ui-changed tmgmt-ui-info-item">',
      '#suffix' => '</div>',
    );
    $statuses = LocalTaskItem::getStatuses();
    $form['info']['status'] = array(
      '#type' => 'item',
      '#title' => t('Status'),
      '#markup' => $statuses[$task_item
        ->getStatus()],
      '#prefix' => '<div class="tmgmt-ui-task-item-status tmgmt-ui-info-item">',
      '#suffix' => '</div>',
      '#value' => $task_item
        ->getStatus(),
    );
    $task = $task_item
      ->getTask();
    $url = $task
      ->toUrl();
    $form['info']['task'] = array(
      '#type' => 'item',
      '#title' => t('Task'),
      '#markup' => Link::fromTextAndUrl($task
        ->label(), $url)
        ->toString(),
      '#prefix' => '<div class="tmgmt-ui-task tmgmt-ui-info-item">',
      '#suffix' => '</div>',
    );
    if ($job
      ->getSetting('job_comment')) {
      $form['job_comment'] = array(
        '#type' => 'item',
        '#title' => t('Job comment'),
        '#markup' => Xss::filter($job
          ->getSetting('job_comment')),
      );
    }
    $form['translation'] = array(
      '#type' => 'container',
    );

    // Build the translation form.
    $data = $task_item
      ->getData();

    // Need to keep the first hierarchy. So flatten must take place inside
    // of the foreach loop.
    $zebra = 'even';
    foreach (Element::children($data) as $key) {
      $flattened = \Drupal::service('tmgmt.data')
        ->flatten($data[$key], $key);
      $form['translation'][$key] = $this
        ->formElement($flattened, $task_item, $zebra);
    }
    $form['footer'] = tmgmt_color_local_review_legend();
    $form['#attached']['library'][] = 'tmgmt/admin';
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  protected function actions(array $form, FormStateInterface $form_state) {

    /** @var LocalTaskItem $task_item */
    $task_item = $this->entity;
    $actions['save_as_completed'] = array(
      '#type' => 'submit',
      '#button_type' => 'primary',
      '#validate' => [
        '::validateSaveAsComplete',
      ],
      '#submit' => [
        '::save',
        '::saveAsComplete',
      ],
      '#access' => $task_item
        ->isPending(),
      '#value' => t('Save as completed'),
    );
    $actions['save'] = array(
      '#type' => 'submit',
      '#submit' => [
        '::save',
      ],
      '#access' => $task_item
        ->isPending(),
      '#value' => t('Save'),
    );
    $job_item = $task_item
      ->getJobItem();
    if ($job_item
      ->getSourcePlugin() instanceof SourcePreviewInterface && $job_item
      ->getSourcePlugin()
      ->getPreviewUrl($job_item)) {
      $actions['preview'] = [
        '#type' => 'submit',
        '#submit' => [
          '::save',
          '::preview',
        ],
        '#access' => $task_item
          ->isPending(),
        '#value' => t('Preview'),
      ];
    }
    return $actions;
  }

  /**
   * Builds a translation form element.
   *
   * @param array $data
   *   Data of the translation.
   * @param LocalTaskItem $item
   *   The LocalTaskItem.
   * @param string $zebra
   *   Tell is translation is odd or even.
   *
   * @return array
   *   Render array with the translation element.
   */
  private function formElement(array $data, LocalTaskItem $item, &$zebra) {
    static $flip = array(
      'even' => 'odd',
      'odd' => 'even',
    );
    $form = [];
    $job = $item
      ->getJobItem()
      ->getJob();
    $language_list = \Drupal::languageManager()
      ->getLanguages();
    foreach (Element::children($data) as $key) {
      if (isset($data[$key]['#text']) && \Drupal::service('tmgmt.data')
        ->filterData($data[$key])) {

        // The char sequence '][' confuses the form API so we need to replace
        // it.
        $target_key = str_replace('][', '|', $key);
        $zebra = $flip[$zebra];
        $form[$target_key] = array(
          '#tree' => TRUE,
          '#theme' => 'tmgmt_local_translation_form_element',
          '#ajaxid' => Html::getUniqueId('tmgmt-local-element-' . $key),
          '#parent_label' => $data[$key]['#parent_label'],
          '#zebra' => $zebra,
        );
        $form[$target_key]['status'] = array(
          '#theme' => 'tmgmt_local_translation_form_element_status',
          '#value' => $this->entity
            ->isCompleted() ? TMGMT_DATA_ITEM_STATE_COMPLETED : $data[$key]['#status'],
        );

        // Manage the height of the texteareas, depending on the lenght of the
        // description. The minimum number of rows is 3 and the maximum is 15.
        $rows = ceil(strlen($data[$key]['#text']) / 100);
        if ($rows < 3) {
          $rows = 3;
        }
        elseif ($rows > 15) {
          $rows = 15;
        }
        $form[$target_key]['source'] = [
          '#type' => 'textarea',
          '#value' => $data[$key]['#text'],
          '#title' => t('Source'),
          '#disabled' => TRUE,
          '#rows' => $rows,
        ];
        $form[$target_key]['translation'] = [
          '#type' => 'textarea',
          '#default_value' => isset($data[$key]['#translation']['#text']) ? $data[$key]['#translation']['#text'] : NULL,
          '#title' => t('Translation'),
          '#disabled' => !$item
            ->isPending(),
          '#rows' => $rows,
          '#allow_focus' => TRUE,
        ];
        if (!empty($data[$key]['#format']) && \Drupal::config('tmgmt.settings')
          ->get('respect_text_format') == '1') {
          $format_id = $data[$key]['#format'];

          /** @var \Drupal\filter\Entity\FilterFormat $format */
          $format = FilterFormat::load($format_id);
          if ($format && $format
            ->access('use')) {

            // In case a user has permission to translate the content using
            // selected text format, add a format id into the list of allowed
            // text formats. Otherwise, no text format will be used.
            $form[$target_key]['source']['#allowed_formats'] = [
              $format_id,
            ];
            $form[$target_key]['translation']['#allowed_formats'] = [
              $format_id,
            ];
            $form[$target_key]['source']['#type'] = 'text_format';
            $form[$target_key]['translation']['#type'] = 'text_format';
          }
        }
        $form[$target_key]['actions'] = array(
          '#type' => 'container',
          '#access' => $item
            ->isPending(),
        );
        $status = $item
          ->getData(\Drupal::service('tmgmt.data')
          ->ensureArrayKey($key), '#status');
        if ($status == TMGMT_DATA_ITEM_STATE_TRANSLATED) {
          $form[$target_key]['actions']['reject-' . $target_key] = array(
            '#type' => 'submit',
            // Unicode character &#x2717 BALLOT X.
            '#value' => '✗',
            '#attributes' => array(
              'title' => t('Reject'),
            ),
            '#name' => 'reject-' . $target_key,
            '#submit' => [
              '::save',
              '::submitStatus',
            ],
            '#ajax' => array(
              'callback' => '::ajaxReviewForm',
              'wrapper' => $form[$target_key]['#ajaxid'],
            ),
            '#tmgmt_local_action' => 'reject',
            '#tmgmt_local_key' => str_replace('][', '|', $key),
          );
        }
        else {
          $form[$target_key]['actions']['finish-' . $target_key] = array(
            '#type' => 'submit',
            // Unicode character &#x2713 CHECK MARK.
            '#value' => '✓',
            '#attributes' => array(
              'title' => t('Finish'),
            ),
            '#name' => 'finish-' . $target_key,
            '#submit' => [
              '::save',
              '::submitStatus',
            ],
            '#ajax' => array(
              'callback' => '::ajaxReviewForm',
              'wrapper' => $form[$target_key]['#ajaxid'],
            ),
            '#tmgmt_local_action' => 'finish',
            '#tmgmt_local_key' => str_replace('][', '|', $key),
          );
        }
      }
    }
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function save(array $form, FormStateInterface $form_state) {
    parent::save($form, $form_state);

    /** @var LocalTaskItem $task_item */
    $task_item = $this->entity;
    $form_state
      ->cleanValues();
    foreach ($form_state
      ->getValues() as $key => $value) {
      if (is_array($value) && isset($value['translation'])) {

        // Update the translation, this will only update the translation in case
        // it has changed. We have two different cases, the first is for nested
        // texts.
        if (is_array($value['translation'])) {
          $update['#translation']['#text'] = $value['translation']['value'];
        }
        else {
          $update['#translation']['#text'] = $value['translation'];
        }
        $task_item
          ->updateData($key, $update);
      }
    }
    $task_item
      ->save();
    if ($form_state
      ->getTriggeringElement()['#value'] == $form['actions']['save']['#value']) {
      $this
        ->messenger()
        ->addStatus(t('The translation for <a href=:task_item>@task_item_title</a> has been saved.', [
        ':task_item' => $task_item
          ->toUrl()
          ->toString(),
        '@task_item_title' => $task_item
          ->label(),
      ]));
    }
    $task = $task_item
      ->getTask();
    $uri = $task
      ->toUrl();
    $form_state
      ->setRedirect($uri
      ->getRouteName(), $uri
      ->getRouteParameters());
  }

  /**
   * Form submit callback for save as completed submit action.
   *
   * Change items to needs review state and task to completed status.
   */
  public function saveAsComplete(array &$form, FormStateInterface $form_state) {

    /** @var \Drupal\tmgmt_local\Entity\LocalTask $task */
    $task = $this->entity
      ->getTask();

    /** @var LocalTaskItem $task_item */
    $task_item = $this->entity;
    $task_item
      ->completed();
    $task_item
      ->save();

    // Mark the task as completed if all assigned job items are at needs done.
    $all_done = TRUE;

    /** @var \Drupal\tmgmt_local\Entity\LocalTaskItem $item */
    foreach ($task
      ->getItems() as $item) {
      if (!$item
        ->isCompleted() && !$item
        ->isClosed()) {
        $all_done = FALSE;
        break;
      }
    }
    if ($all_done) {
      $task
        ->setStatus(LocalTaskInterface::STATUS_COMPLETED);

      // If the task is now completed, redirect back to the overview.
      $view = Views::getView('tmgmt_local_task_overview');
      $view
        ->initDisplay();
      $form_state
        ->setRedirect($view
        ->getUrl()
        ->getRouteName());
    }
    else {

      // If there are more task items, redirect back to the task.
      $uri = $task
        ->toUrl();
      $form_state
        ->setRedirect($uri
        ->getRouteName(), $uri
        ->getRouteParameters());
    }

    /** @var \Drupal\tmgmt\Entity\JobItem $job_item */
    $job_item = $this->entity
      ->getJobItem();

    // Add the translations to the job item.
    $job_item
      ->addTranslatedData($this
      ->prepareData($task_item
      ->getData()), [], TMGMT_DATA_ITEM_STATE_TRANSLATED);
    $this
      ->messenger()
      ->addStatus(t('The translation for <a href=:task_item>@task_item_title</a> has been saved as completed.', [
      ':task_item' => $task_item
        ->toUrl()
        ->toString(),
      '@task_item_title' => $task_item
        ->label(),
    ]));
  }

  /**
   * Form validate callback for save as completed submit action.
   *
   * Verify that all items are translated.
   */
  public function validateSaveAsComplete(array &$form, FormStateInterface $form_state) {

    // Loop over all data items and verify that there is a translation in there.
    foreach ($form_state
      ->getValues() as $key => $value) {
      if (is_array($value) && isset($value['translation'])) {
        if (empty($value['translation'])) {
          $form_state
            ->setErrorByName($key . '[translation]', t('Missing translation.'));
        }
      }
    }
  }

  /**
   * Ajax callback for the job item review form.
   */
  public function ajaxReviewForm(array $form, FormStateInterface $form_state) {
    $key = array_slice($form_state
      ->getTriggeringElement()['#array_parents'], 0, 3);
    $render_data = NestedArray::getValue($form, $key);
    return $render_data;
  }

  /**
   * Form submit callback for the translation state update button.
   */
  public function submitStatus(array $form, FormStateInterface $form_state) {
    $values = $form_state
      ->getValues();

    /** @var \Drupal\tmgmt_local\Entity\LocalTaskItem $item */
    $item = $this->entity;
    $action = $form_state
      ->getTriggeringElement()['#tmgmt_local_action'];
    $key = $form_state
      ->getTriggeringElement()['#tmgmt_local_key'];

    // Write the translated data into the job item.
    if (isset($values[$key]) && is_array($values[$key]) && isset($values[$key]['translation'])) {
      $update['#status'] = $action == 'finish' ? TMGMT_DATA_ITEM_STATE_TRANSLATED : TMGMT_DATA_ITEM_STATE_UNTRANSLATED;
      $item
        ->updateData($key, $update);
      $item
        ->save();

      // We need to rebuild form so we get updated action button state.
      $form_state
        ->setRebuild();
    }
  }

  /**
   * Prepare the date to be added to the JobItem.
   *
   * Right now JobItem looks for ['#text'] so if we send our structure it will
   * add as translation text our original text, so we are replacing ['#text']
   * with ['#translation']['#text']
   *
   * @param array $data
   *   The data items.
   *
   * @return array
   *   Returns the data items ready to be added to the JobItem.
   */
  protected function prepareData(array $data) {
    if (isset($data['#text'])) {
      if (isset($data['#translation']['#text'])) {
        $result['#text'] = $data['#translation']['#text'];
      }
      else {
        $result['#text'] = '';
      }
      return $result;
    }
    foreach (Element::children($data) as $key) {
      $data[$key] = $this
        ->prepareData($data[$key]);
    }
    return $data;
  }

  /**
   * Form submit callback for the preview button.
   */
  public function preview(array $form, FormStateInterface $form_state) {
    $task_item = $this->entity;
    $job_item = $task_item
      ->getJobItem();
    $job_item
      ->addTranslatedData($this
      ->prepareData($task_item
      ->getData()), [], TMGMT_DATA_ITEM_STATE_PRELIMINARY);

    /** @var \Drupal\Core\Url $url */
    $url = $job_item
      ->getSourcePlugin()
      ->getPreviewUrl($job_item);
    $form_state
      ->setRedirectUrl($url);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ContentEntityForm::$entityRepository protected property The entity repository service.
ContentEntityForm::$entityTypeBundleInfo protected property The entity type bundle info service.
ContentEntityForm::$time protected property The time service.
ContentEntityForm::addRevisionableFormFields protected function Add revision form fields if the entity enabled the UI.
ContentEntityForm::buildEntity public function Builds an updated entity object based upon the submitted form values. Overrides EntityForm::buildEntity 3
ContentEntityForm::copyFormValuesToEntity protected function Copies top-level form values to entity properties Overrides EntityForm::copyFormValuesToEntity
ContentEntityForm::create public static function Instantiates a new instance of this class. Overrides FormBase::create 9
ContentEntityForm::flagViolations protected function Flags violations for the current form. 4
ContentEntityForm::getBundleEntity protected function Returns the bundle entity of the entity, or NULL if there is none.
ContentEntityForm::getEditedFieldNames protected function Gets the names of all fields edited in the form. 4
ContentEntityForm::getFormDisplay public function Gets the form display. Overrides ContentEntityFormInterface::getFormDisplay
ContentEntityForm::getFormLangcode public function Gets the code identifying the active form language. Overrides ContentEntityFormInterface::getFormLangcode
ContentEntityForm::getNewRevisionDefault protected function Should new revisions created on default.
ContentEntityForm::init protected function Initializes the form state and the entity before the first form build. Overrides EntityForm::init 1
ContentEntityForm::initFormLangcodes protected function Initializes form language code values.
ContentEntityForm::isDefaultFormLangcode public function Checks whether the current form language matches the entity one. Overrides ContentEntityFormInterface::isDefaultFormLangcode
ContentEntityForm::prepareEntity protected function Prepares the entity object before the form is built first. Overrides EntityForm::prepareEntity 1
ContentEntityForm::setFormDisplay public function Sets the form display. Overrides ContentEntityFormInterface::setFormDisplay
ContentEntityForm::showRevisionUi protected function Checks whether the revision form fields should be added to the form.
ContentEntityForm::submitForm public function This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state… Overrides EntityForm::submitForm 3
ContentEntityForm::updateChangedTime public function Updates the changed time of the entity.
ContentEntityForm::updateFormLangcode public function Updates the form language to reflect any change to the entity language.
ContentEntityForm::validateForm public function Button-level validation handlers are highly discouraged for entity forms, as they will prevent entity validation from running. If the entity is going to be saved during the form submission, this method should be manually invoked from the button-level… Overrides FormBase::validateForm 3
ContentEntityForm::__construct public function Constructs a ContentEntityForm object. 9
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 1
DependencySerializationTrait::__wakeup public function 2
EntityForm::$entityTypeManager protected property The entity type manager. 3
EntityForm::$moduleHandler protected property The module handler service.
EntityForm::$operation protected property The name of the current operation.
EntityForm::$privateEntityManager private property The entity manager.
EntityForm::actionsElement protected function Returns the action form element for the current entity form.
EntityForm::afterBuild public function Form element #after_build callback: Updates the entity with submitted data.
EntityForm::buildForm public function Form constructor. Overrides FormInterface::buildForm 10
EntityForm::getBaseFormId public function Returns a string identifying the base form. Overrides BaseFormIdInterface::getBaseFormId 5
EntityForm::getEntity public function Gets the form entity. Overrides EntityFormInterface::getEntity
EntityForm::getEntityFromRouteMatch public function Determines which entity will be used by this form from a RouteMatch object. Overrides EntityFormInterface::getEntityFromRouteMatch 1
EntityForm::getFormId public function Returns a unique string identifying the form. Overrides FormInterface::getFormId 10
EntityForm::getOperation public function Gets the operation identifying the form. Overrides EntityFormInterface::getOperation
EntityForm::prepareInvokeAll protected function Invokes the specified prepare hook variant.
EntityForm::processForm public function Process callback: assigns weights and hides extra fields.
EntityForm::setEntity public function Sets the form entity. Overrides EntityFormInterface::setEntity
EntityForm::setEntityManager public function Sets the entity manager for this form. Overrides EntityFormInterface::setEntityManager
EntityForm::setEntityTypeManager public function Sets the entity type manager for this form. Overrides EntityFormInterface::setEntityTypeManager
EntityForm::setModuleHandler public function Sets the module handler for this form. Overrides EntityFormInterface::setModuleHandler
EntityForm::setOperation public function Sets the operation for this form. Overrides EntityFormInterface::setOperation
EntityForm::__get public function
EntityForm::__set public function
FormBase::$configFactory protected property The config factory. 1
FormBase::$requestStack protected property The request stack. 1
FormBase::$routeMatch protected property The route match.
FormBase::config protected function Retrieves a configuration object.
FormBase::configFactory protected function Gets the config factory for this form. 1
FormBase::container private function Returns the service container.
FormBase::currentUser protected function Gets the current user.
FormBase::getRequest protected function Gets the request object.
FormBase::getRouteMatch protected function Gets the route match.
FormBase::logger protected function Gets the logger for a specific channel.
FormBase::redirect protected function Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait::redirect
FormBase::resetConfigFactory public function Resets the configuration factory.
FormBase::setConfigFactory public function Sets the config factory for this form.
FormBase::setRequestStack public function Sets the request stack object to use.
LinkGeneratorTrait::$linkGenerator protected property The link generator. 1
LinkGeneratorTrait::getLinkGenerator Deprecated protected function Returns the link generator.
LinkGeneratorTrait::l Deprecated protected function Renders a link to a route given a route name and its parameters.
LinkGeneratorTrait::setLinkGenerator Deprecated public function Sets the link generator service.
LocalTaskItemForm::$entity protected property The task item. Overrides ContentEntityForm::$entity
LocalTaskItemForm::actions protected function Returns an array of supported actions for the current entity form. Overrides EntityForm::actions
LocalTaskItemForm::ajaxReviewForm public function Ajax callback for the job item review form.
LocalTaskItemForm::form public function Gets the actual form array to be built. Overrides ContentEntityForm::form
LocalTaskItemForm::formElement private function Builds a translation form element.
LocalTaskItemForm::prepareData protected function Prepare the date to be added to the JobItem.
LocalTaskItemForm::preview public function Form submit callback for the preview button.
LocalTaskItemForm::save public function Form submission handler for the 'save' action. Overrides EntityForm::save
LocalTaskItemForm::saveAsComplete public function Form submit callback for save as completed submit action.
LocalTaskItemForm::submitStatus public function Form submit callback for the translation state update button.
LocalTaskItemForm::validateSaveAsComplete public function Form validate callback for save as completed submit action.
LoggerChannelTrait::$loggerFactory protected property The logger channel factory service.
LoggerChannelTrait::getLogger protected function Gets the logger for a specific channel.
LoggerChannelTrait::setLoggerFactory public function Injects the logger channel factory.
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
RedirectDestinationTrait::$redirectDestination protected property The redirect destination service. 1
RedirectDestinationTrait::getDestinationArray protected function Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url.
RedirectDestinationTrait::getRedirectDestination protected function Returns the redirect destination service.
RedirectDestinationTrait::setRedirectDestination public function Sets the redirect destination service.
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.
UrlGeneratorTrait::$urlGenerator protected property The url generator.
UrlGeneratorTrait::getUrlGenerator Deprecated protected function Returns the URL generator service.
UrlGeneratorTrait::setUrlGenerator Deprecated public function Sets the URL generator service.
UrlGeneratorTrait::url Deprecated protected function Generates a URL or path for a specific route based on the given parameters.