You are here

public function Job::getTranslator in Translation Management Tool 8

Returns the translator for this job.

Return value

\Drupal\tmgmt\Entity\Translator The translator entity.

Throws

\Drupal\tmgmt\TMGMTException Throws an exception when there is no translator assigned or when the translator is missing the plugin.

Overrides JobInterface::getTranslator

1 call to Job::getTranslator()
Job::canRequestTranslation in src/Entity/Job.php
Checks whether a job is translatable.

File

src/Entity/Job.php, line 520

Class

Job
Entity class for the tmgmt_job entity.

Namespace

Drupal\tmgmt\Entity

Code

public function getTranslator() {
  if ($this
    ->hasTranslator()) {
    return $this->translator->entity;
  }
  else {
    if (!$this->translator->entity) {
      throw new TMGMTException('The job has no provider assigned.');
    }
    else {
      if (!$this->translator->entity
        ->hasPlugin()) {
        throw new TMGMTException('The translator assigned to this job is missing the plugin.');
      }
    }
  }
}