LingotekInterfaceTranslationClearMetadataForm.php in Lingotek Translation 3.5.x        
                          
                  
                        
  
  
  
  
File
  src/Form/LingotekInterfaceTranslationClearMetadataForm.php
  
    View source  
  <?php
namespace Drupal\lingotek\Form;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\lingotek\LingotekInterfaceTranslationServiceInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class LingotekInterfaceTranslationClearMetadataForm extends ConfirmFormBase {
  
  protected $lingotekInterfaceTranslation;
  
  public function __construct(LingotekInterfaceTranslationServiceInterface $lingotek_interface_translation) {
    $this->lingotekInterfaceTranslation = $lingotek_interface_translation;
  }
  
  public static function create(ContainerInterface $container) {
    return new static($container
      ->get('lingotek.interface_translation'));
  }
  
  public function getFormId() {
    return 'lingotek_interface_translation_clear_metadata_form';
  }
  
  public function getQuestion() {
    return $this
      ->t('Are you sure you want to clear the Lingotek metadata?');
  }
  
  public function getDescription() {
    return $this
      ->t("This will remove the metadata stored about your Lingotek interface translations, so you will need to re-upload those in case you want to translate them. This operation won't remove any interface translations from your Drupal site.") . ' ' . $this
      ->t('This action cannot be undone.');
  }
  
  public function getConfirmText() {
    return $this
      ->t('Clear metadata');
  }
  
  public function getCancelUrl() {
    return new Url('lingotek.manage_interface_translation');
  }
  
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->lingotekInterfaceTranslation
      ->deleteAllMetadata();
    $this
      ->logger('lingotek')
      ->notice('Cleared interface translation Lingotek metadata.');
    $this
      ->messenger()
      ->addStatus($this
      ->t('You have cleared the Lingotek metadata for interface translations.'));
    $form_state
      ->setRedirectUrl($this
      ->getCancelUrl());
  }
}