You are here

class LingotekJobManagementContentEntitiesForm in Lingotek Translation 3.4.x

Same name and namespace in other branches
  1. 8.2 src/Form/LingotekJobManagementContentEntitiesForm.php \Drupal\lingotek\Form\LingotekJobManagementContentEntitiesForm
  2. 4.0.x src/Form/LingotekJobManagementContentEntitiesForm.php \Drupal\lingotek\Form\LingotekJobManagementContentEntitiesForm
  3. 3.0.x src/Form/LingotekJobManagementContentEntitiesForm.php \Drupal\lingotek\Form\LingotekJobManagementContentEntitiesForm
  4. 3.1.x src/Form/LingotekJobManagementContentEntitiesForm.php \Drupal\lingotek\Form\LingotekJobManagementContentEntitiesForm
  5. 3.2.x src/Form/LingotekJobManagementContentEntitiesForm.php \Drupal\lingotek\Form\LingotekJobManagementContentEntitiesForm
  6. 3.3.x src/Form/LingotekJobManagementContentEntitiesForm.php \Drupal\lingotek\Form\LingotekJobManagementContentEntitiesForm
  7. 3.5.x src/Form/LingotekJobManagementContentEntitiesForm.php \Drupal\lingotek\Form\LingotekJobManagementContentEntitiesForm
  8. 3.6.x src/Form/LingotekJobManagementContentEntitiesForm.php \Drupal\lingotek\Form\LingotekJobManagementContentEntitiesForm
  9. 3.7.x src/Form/LingotekJobManagementContentEntitiesForm.php \Drupal\lingotek\Form\LingotekJobManagementContentEntitiesForm
  10. 3.8.x src/Form/LingotekJobManagementContentEntitiesForm.php \Drupal\lingotek\Form\LingotekJobManagementContentEntitiesForm

Form for bulk management of job filtered content.

Hierarchy

Expanded class hierarchy of LingotekJobManagementContentEntitiesForm

1 string reference to 'LingotekJobManagementContentEntitiesForm'
lingotek.routing.yml in ./lingotek.routing.yml
lingotek.routing.yml

File

src/Form/LingotekJobManagementContentEntitiesForm.php, line 25

Namespace

Drupal\lingotek\Form
View source
class LingotekJobManagementContentEntitiesForm extends LingotekManagementFormBase {

  /**
   * The job ID
   *
   * @var string
   */
  protected $jobId;

  /**
   * Constructs a new LingotekJobManagementContentEntitiesForm object.
   *
   * @param \Drupal\Core\Database\Connection $connection
   *   The current database connection.
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity manager.
   * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
   *   The language manager.
   * @param \Drupal\lingotek\LingotekInterface $lingotek
   *   The lingotek service.
   * @param \Drupal\lingotek\LingotekConfigurationServiceInterface $lingotek_configuration
   *   The Lingotek configuration service.
   * @param \Drupal\lingotek\LanguageLocaleMapperInterface $language_locale_mapper
   *   The language-locale mapper.
   * @param \Drupal\content_translation\ContentTranslationManagerInterface $content_translation_manager
   *   The content translation manager.
   * @param \Drupal\lingotek\LingotekContentTranslationServiceInterface $translation_service
   *   The Lingotek content translation service.
   * @param \Drupal\Core\TempStore\PrivateTempStoreFactory $temp_store_factory
   *   The factory for the temp store object.
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
   *   The module handler.
   * @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager
   *   The entity field manager.
   * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info
   *   The entity type bundle info.
   * @param \Drupal\Core\Utility\LinkGeneratorInterface $link_generator
   *   The link generator.
   */
  public function __construct(Connection $connection, EntityTypeManagerInterface $entity_type_manager, LanguageManagerInterface $language_manager, LingotekInterface $lingotek, LingotekConfigurationServiceInterface $lingotek_configuration, LanguageLocaleMapperInterface $language_locale_mapper, ContentTranslationManagerInterface $content_translation_manager, LingotekContentTranslationServiceInterface $translation_service, PrivateTempStoreFactory $temp_store_factory, StateInterface $state, ModuleHandlerInterface $module_handler, EntityFieldManagerInterface $entity_field_manager = NULL, EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL, LinkGeneratorInterface $link_generator = NULL) {
    parent::__construct($connection, $entity_type_manager, $language_manager, $lingotek, $lingotek_configuration, $language_locale_mapper, $content_translation_manager, $translation_service, $temp_store_factory, $state, $module_handler, NULL, $entity_field_manager, $entity_type_bundle_info, $link_generator);
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static($container
      ->get('database'), $container
      ->get('entity_type.manager'), $container
      ->get('language_manager'), $container
      ->get('lingotek'), $container
      ->get('lingotek.configuration'), $container
      ->get('lingotek.language_locale_mapper'), $container
      ->get('content_translation.manager'), $container
      ->get('lingotek.content_translation'), $container
      ->get('tempstore.private'), $container
      ->get('state'), $container
      ->get('module_handler'), $container
      ->get('entity_field.manager'), $container
      ->get('entity_type.bundle.info'), $container
      ->get('link_generator'));
  }
  public function buildForm(array $form, FormStateInterface $form_state, $job_id = NULL) {
    $this->jobId = $job_id;
    $form = parent::buildForm($form, $form_state);
    $form['filters']['wrapper']['job']['#access'] = FALSE;
    return $form;
  }
  protected function getBulkOptions() {
    $options = parent::getBulkOptions();
    $options['show_advanced']['#access'] = FALSE;
    $options['job_id']['#access'] = FALSE;
    $options['job_id']['#default_value'] = $this->jobId;
    return $options;
  }
  protected function getFilteredEntities() {
    $entity_query = $this->entityTypeManager
      ->getStorage('lingotek_content_metadata')
      ->getQuery();
    $entity_query
      ->condition('job_id', $this->jobId);
    $ids = $entity_query
      ->execute();
    $metadatas = $this->entityTypeManager
      ->getStorage('lingotek_content_metadata')
      ->loadMultiple($ids);
    $entities = [];

    /** @var \Drupal\lingotek\Entity\LingotekContentMetadata $metadata */
    foreach ($metadatas as $metadata) {
      $content_entity_type_id = $metadata
        ->getContentEntityTypeId();
      $content_entity_id = $metadata
        ->getContentEntityId();
      $entity = $this->entityTypeManager
        ->getStorage($content_entity_type_id)
        ->load($content_entity_id);
      $entities[$content_entity_type_id][] = $entity;
    }
    return $entities;
  }
  protected function getSelectedEntities($values) {
    $entityTypes = [];
    $entities = [];
    foreach ($values as $type_entity_id) {
      list($type, $entity_id) = explode(":", $type_entity_id);
      $entityTypes[$type][] = $entity_id;
    }
    foreach ($entityTypes as $type => $values) {
      $entities = array_merge($entities, $this->entityTypeManager
        ->getStorage($type)
        ->loadMultiple($values));
    }
    return $entities;
  }

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'lingotek_job_content_entities_management';
  }

  /**
   * {@inheritdoc}
   */
  protected function getHeaders() {
    $headers = [
      'label' => $this
        ->t('Label'),
      'entity_type_id' => $this
        ->t('Content Type'),
      'bundle' => $this
        ->t('Bundle'),
      'source' => $this
        ->t('Source'),
      'translations' => $this
        ->t('Translations'),
      'profile' => $this
        ->t('Profile'),
      'job_id' => $this
        ->t('Job ID'),
    ];
    return $headers;
  }
  protected function getRows($entity_list) {
    $counter = 1;
    $rows = [];
    foreach ($entity_list as $entity_type_id => $entities) {
      foreach ($entities as $entity_id => $entity) {
        $rowId = (string) $entity
          ->getEntityTypeId() . ':' . (string) $entity
          ->id();
        $rows[$rowId] = $this
          ->getRow($entity);
        $counter += 1;
      }
    }
    return $rows;
  }
  protected function getRow($entity) {
    $row = parent::getRow($entity);
    $bundleInfo = $this->entityTypeBundleInfo
      ->getBundleInfo($entity
      ->getEntityTypeId());
    if ($entity
      ->hasLinkTemplate('canonical')) {
      $row['label'] = $entity
        ->toLink();
    }
    else {
      $row['label'] = $entity
        ->label();
    }
    $row['entity_type_id'] = $entity
      ->getEntityType()
      ->getLabel();
    $row['bundle'] = $bundleInfo[$entity
      ->bundle()]['label'];
    return $row;
  }

  /**
   * Gets the key used for persisting filtering options in the temp storage.
   *
   * @return string
   *   Temp storage identifier where filters are persisted.
   */
  protected function getTempStorageFilterKey() {
    return NULL;
  }

  /**
   * Gets the filter keys so we can persist or clear filtering options.
   *
   * @return string[]
   *   Array of filter identifiers.
   */
  protected function getFilterKeys() {
    return NULL;
  }

  /**
   * Gets the filters for rendering.
   *
   * @return array
   *   A form array.
   */
  protected function getFilters() {
    return NULL;
  }

  /**
   * {@inheritdoc}
   */
  protected function getPager() {
    return NULL;
  }

  /**
   * {@inheritdoc}
   */
  protected function canHaveDeleteTranslationBulkOptions() {
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  protected function canHaveDeleteBulkOptions() {
    return FALSE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property
DependencySerializationTrait::$_serviceIds protected property
DependencySerializationTrait::__sleep public function 2
DependencySerializationTrait::__wakeup public function 2
FormBase::$configFactory protected property The config factory. 3
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. 3
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.
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.
FormBase::validateForm public function Form validation handler. Overrides FormInterface::validateForm 72
LingotekJobManagementContentEntitiesForm::$jobId protected property The job ID
LingotekJobManagementContentEntitiesForm::buildForm public function Form constructor. Overrides LingotekManagementFormBase::buildForm
LingotekJobManagementContentEntitiesForm::canHaveDeleteBulkOptions protected function Check if we can delete content in bulk based on the entity definition. Overrides LingotekManagementFormBase::canHaveDeleteBulkOptions
LingotekJobManagementContentEntitiesForm::canHaveDeleteTranslationBulkOptions protected function Check if we can delete translation in bulk based on the entity definition. Overrides LingotekManagementFormBase::canHaveDeleteTranslationBulkOptions
LingotekJobManagementContentEntitiesForm::create public static function Instantiates a new instance of this class. Overrides LingotekManagementFormBase::create
LingotekJobManagementContentEntitiesForm::getBulkOptions protected function Gets the bulk options form array structure. Overrides LingotekManagementFormBase::getBulkOptions
LingotekJobManagementContentEntitiesForm::getFilteredEntities protected function Gets the entities that needs to be displayed based on the current filters. Overrides LingotekManagementFormBase::getFilteredEntities
LingotekJobManagementContentEntitiesForm::getFilterKeys protected function Gets the filter keys so we can persist or clear filtering options. Overrides LingotekManagementFormBase::getFilterKeys
LingotekJobManagementContentEntitiesForm::getFilters protected function Gets the filters for rendering. Overrides LingotekManagementFormBase::getFilters
LingotekJobManagementContentEntitiesForm::getFormId public function Returns a unique string identifying the form. Overrides FormInterface::getFormId
LingotekJobManagementContentEntitiesForm::getHeaders protected function Overrides LingotekManagementFormBase::getHeaders
LingotekJobManagementContentEntitiesForm::getPager protected function Gets the pager. Overrides LingotekManagementFormBase::getPager
LingotekJobManagementContentEntitiesForm::getRow protected function Gets a rows fo rendering based on the passed entity. Overrides LingotekManagementFormBase::getRow
LingotekJobManagementContentEntitiesForm::getRows protected function Gets the rows for rendering based on the passed entity list. Overrides LingotekManagementFormBase::getRows
LingotekJobManagementContentEntitiesForm::getSelectedEntities protected function Load the entities corresponding with the given identifiers. Overrides LingotekManagementFormBase::getSelectedEntities
LingotekJobManagementContentEntitiesForm::getTempStorageFilterKey protected function Gets the key used for persisting filtering options in the temp storage. Overrides LingotekManagementFormBase::getTempStorageFilterKey
LingotekJobManagementContentEntitiesForm::__construct public function Constructs a new LingotekJobManagementContentEntitiesForm object. Overrides LingotekManagementFormBase::__construct
LingotekManagementFormBase::$connection protected property The connection object on which to run queries.
LingotekManagementFormBase::$contentTranslationManager protected property The content translation manager.
LingotekManagementFormBase::$entityFieldManager protected property The entity field manager.
LingotekManagementFormBase::$entityTypeBundleInfo protected property The entity type bundle info.
LingotekManagementFormBase::$entityTypeId protected property The entity type id.
LingotekManagementFormBase::$entityTypeManager protected property The entity manager.
LingotekManagementFormBase::$languageLocaleMapper protected property The language-locale mapper.
LingotekManagementFormBase::$languageManager protected property The language manager.
LingotekManagementFormBase::$lingotekConfiguration protected property The Lingotek configuration service.
LingotekManagementFormBase::$moduleHandler protected property The module handler.
LingotekManagementFormBase::$state protected property The state key value store.
LingotekManagementFormBase::$translationService protected property The Lingotek content translation service.
LingotekManagementFormBase::batchFinished public function Batch callback called when the batch finishes.
LingotekManagementFormBase::cancel public function Cancel the content from Lingotek.
LingotekManagementFormBase::cancelTarget public function Cancel the content from Lingotek.
LingotekManagementFormBase::changeProfile public function Change Translation Profile.
LingotekManagementFormBase::checkDocumentUploadStatus public function Check document upload status for a given content.
LingotekManagementFormBase::checkTranslationStatus public function Checks translation status for a given content in a given language.
LingotekManagementFormBase::checkTranslationStatuses public function Checks all translations statuses for a given content.
LingotekManagementFormBase::createBatch protected function Performs an operation to several values in a batch.
LingotekManagementFormBase::createCancelBatch protected function Create and set a cancellation batch.
LingotekManagementFormBase::createChangeProfileBatch protected function Create and set a profile change batch.
LingotekManagementFormBase::createDebugExportBatch protected function Create and set an export batch.
LingotekManagementFormBase::createDownloadBatch protected function Create and set a request target and download batch for all languages.
LingotekManagementFormBase::createLanguageDownloadBatch protected function Create and set a request target and download batch for a given language.
LingotekManagementFormBase::createLanguageRequestTranslationBatch protected function Create and set a request translations batch for all languages.
LingotekManagementFormBase::createLanguageTranslationCheckStatusBatch protected function Create and set a check translation status batch for a given language.
LingotekManagementFormBase::createRequestTranslationsBatch protected function Create and set a request translations batch for all languages.
LingotekManagementFormBase::createTargetCancelBatch protected function Create and set a target cancellation batch.
LingotekManagementFormBase::createTranslationCheckStatusBatch protected function Create and set a check translation status batch for all languages.
LingotekManagementFormBase::createUploadBatch protected function Create and set an upload batch.
LingotekManagementFormBase::createUploadCheckStatusBatch protected function Create and set a check upload status batch.
LingotekManagementFormBase::debugExport public function Export source for debugging purposes.
LingotekManagementFormBase::debugExportFinished public function Batch callback called when the debug export batch finishes.
LingotekManagementFormBase::downloadTranslation public function Download translation for a given content in a given language.
LingotekManagementFormBase::downloadTranslations public function Download translations for a given content in all enabled languages.
LingotekManagementFormBase::filterForm public function Form submission handler for filtering.
LingotekManagementFormBase::generateBulkOptions public function Get the bulk operations for the management form.
LingotekManagementFormBase::getAllBundles protected function Gets all the bundles as options.
LingotekManagementFormBase::getAllGroups protected function Gets all the groups as options.
LingotekManagementFormBase::getAllLanguages protected function Gets all the languages as options.
LingotekManagementFormBase::getDestinationWithQueryArray protected function
LingotekManagementFormBase::getSourceStatus protected function Gets the source status of an entity in a format ready to display.
LingotekManagementFormBase::getTranslationsStatuses protected function Gets the translation status of an entity in a format ready to display.
LingotekManagementFormBase::redirectToAssignJobIdMultipleEntitiesForm protected function Redirect to assign Job ID form.
LingotekManagementFormBase::redirectToClearJobIdMultipleEntitiesForm protected function Redirect to clear Job ID form.
LingotekManagementFormBase::redirectToDeleteMultipleNodesForm protected function Redirect to delete content form.
LingotekManagementFormBase::redirectToDeleteMultipleTranslationsForm protected function Redirect to delete translations form.
LingotekManagementFormBase::redirectToDeleteTranslationForm protected function Redirect to delete specific translation form.
LingotekManagementFormBase::requestTranslation public function Request translations for a given content in a given language.
LingotekManagementFormBase::requestTranslations public function Request all translations for a given content.
LingotekManagementFormBase::resetFilterForm public function Form submission handler for resetting the filters.
LingotekManagementFormBase::submitForm public function Form submission handler. Overrides FormInterface::submitForm
LingotekManagementFormBase::uploadDocument public function Upload source for translation.
LingotekManagementFormHelperTrait::$tempStoreFactory protected property The tempstore factory.
LingotekManagementFormHelperTrait::getItemsPerPage protected function
LingotekManagementFormHelperTrait::setItemsPerPage protected function
LingotekSetupTrait::$lingotek protected property A lingotek connector object
LingotekSetupTrait::checkSetup protected function Verify the Lingotek Translation module has been properly initialized.
LingotekSetupTrait::setupCompleted public function Checks if Lingotek module is completely set up.
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. 27
MessengerTrait::messenger public function Gets the messenger. 27
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. 4
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.