/** * {@inheritdoc} */ protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) { $installed_translators = $this->translatorManager->getLabels(); if (empty($installed_translators)) { return AccessResult::forbidden(); } return AccessResult::allowedIfHasPermission($account, 'administer tmgmt'); }
/** * {@inheritdoc} */ public function buildHeader() { $header['label'] = t('Translator name'); $installed_translators = $this->translatorManager->getLabels(); if (empty($installed_translators)) { drupal_set_message(t("There are no provider plugins available. Please install a provider plugin."), 'error'); } return $header + parent::buildHeader(); }
/** * {@inheritdoc} */ public function validateForm(array &$form, FormStateInterface $form_state) { parent::validateForm($form, $form_state); if (!$form_state->getValue('plugin')) { $form_state->setErrorByName('plugin', $this->t('You have to select a translator plugin.')); } $plugin_ui = $this->translatorManager->createUIInstance($this->entity->getPluginID()); $plugin_ui->validateConfigurationForm($form, $form_state); }
/** * Returns TRUE if there are translators that support continuous jobs. */ public function checkIfContinuousTranslatorAvailable() { $translator_plugins = $this->translatorManager->getDefinitions(); foreach ($translator_plugins as $type => $definition) { $translator_type = $this->translatorManager->createInstance($type); if ($translator_type instanceof ContinuousTranslatorInterface) { return TRUE; } } return FALSE; }