isPendingRevisionSupportEnabled example


  protected function alterRoutes(RouteCollection $collection) {
    foreach ($this->contentTranslationManager->getSupportedEntityTypes() as $entity_type_id => $entity_type) {
      // Inherit admin route status from edit route, if exists.       $is_admin = FALSE;
      $route_name = "entity.$entity_type_id.edit_form";
      if ($edit_route = $collection->get($route_name)) {
        $is_admin = (bool) $edit_route->getOption('_admin_route');
      }

      $load_latest_revision = ContentTranslationManager::isPendingRevisionSupportEnabled($entity_type_id);

      if ($entity_type->hasLinkTemplate('drupal:content-translation-overview')) {
        $route = new Route(
          $entity_type->getLinkTemplate('drupal:content-translation-overview'),
          [
            '_controller' => '\Drupal\content_translation\Controller\ContentTranslationController::overview',
            'entity_type_id' => $entity_type_id,
          ],
          [
            '_entity_access' => $entity_type_id . '.view',
            '_access_content_translation_overview' => $entity_type_id,
          ],

  public function overview(RouteMatchInterface $route_match$entity_type_id = NULL) {
    /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
    $entity = $route_match->getParameter($entity_type_id);
    $account = $this->currentUser();
    $handler = $this->entityTypeManager()->getHandler($entity_type_id, 'translation');
    $manager = $this->manager;
    $entity_type = $entity->getEntityType();
    $use_latest_revisions = $entity_type->isRevisionable() && ContentTranslationManager::isPendingRevisionSupportEnabled($entity_type_id$entity->bundle());

    // Start collecting the cacheability metadata, starting with the entity and     // later merge in the access result cacheability metadata.     $cacheability = CacheableMetadata::createFromObject($entity);

    $languages = $this->languageManager()->getLanguages();
    $original = $entity->getUntranslated()->language()->getId();
    $translations = $entity->getTranslationLanguages();
    $field_ui = $this->moduleHandler()->moduleExists('field_ui') && $account->hasPermission('administer ' . $entity_type_id . ' fields');

    $rows = [];
    
t('Only this translation is published. You must publish at least one more translation to unpublish this one.');

      $form['content_translation']['status'] = [
        '#type' => 'checkbox',
        '#title' => t('This translation is published'),
        '#default_value' => $status,
        '#description' => $description,
        '#disabled' => !$enabled,
      ];

      $translate = !$new_translation && $metadata->isOutdated();
      $outdated_access = !ContentTranslationManager::isPendingRevisionSupportEnabled($entity->getEntityTypeId()$entity->bundle());
      if (!$outdated_access) {
        $form['content_translation']['outdated'] = [
          '#markup' => $this->t('Translations cannot be flagged as outdated when content is moderated.'),
        ];
      }
      elseif (!$translate) {
        $form['content_translation']['retranslate'] = [
          '#type' => 'checkbox',
          '#title' => t('Flag other translations as outdated'),
          '#default_value' => FALSE,
          '#description' => t('If you made a significant change, which means the other translations should be updated, you can flag all translations of this content as outdated. This will not change any other property of them, like whether they are published or not.'),
          
$result = AccessResult::allowed();

    $entity_type_id = $entity->getEntityTypeId();
    $result->addCacheableDependency($entity);
    // Add the cache dependencies used by     // ContentTranslationManager::isPendingRevisionSupportEnabled().     if (\Drupal::moduleHandler()->moduleExists('content_moderation')) {
      foreach (Workflow::loadMultipleByType('content_moderation') as $workflow) {
        $result->addCacheableDependency($workflow);
      }
    }
    if (!ContentTranslationManager::isPendingRevisionSupportEnabled($entity_type_id$entity->bundle())) {
      return $result;
    }

    if ($entity->isDefaultTranslation()) {
      return $result;
    }

    $config = ContentLanguageSettings::load($entity_type_id . '.' . $entity->bundle());
    $result->addCacheableDependency($config);
    if (!$this->contentTranslationManager->isEnabled($entity_type_id$entity->bundle())) {
      return $result;
    }
Home | Imprint | This part of the site doesn't use cookies.