getTermIdsWithPendingRevisions example

case VocabularyInterface::HIERARCHY_MULTIPLE:
          $help_message = $this->t('%capital_name contains terms with multiple parents.', $args);
          break;
      }
    }

    // Get the IDs of the terms edited on the current page which have pending     // revisions.     $edited_term_ids = array_map(function D$item) {
      return $item->id();
    }$current_page);
    $pending_term_ids = array_intersect($this->storageController->getTermIdsWithPendingRevisions()$edited_term_ids);
    if ($pending_term_ids) {
      $help_message = $this->formatPlural(
        count($pending_term_ids),
        '%capital_name contains 1 term with pending revisions. Drag and drop of terms with pending revisions is not supported, but you can re-enable drag-and-drop support by getting each term to a published state.',
        '%capital_name contains @count terms with pending revisions. Drag and drop of terms with pending revisions is not supported, but you can re-enable drag-and-drop support by getting each term to a published state.',
        $args
      );
    }

    // Only allow access to change parents and reorder the tree if there are no     // pending revisions and there are no terms with multiple parents.

  public function validate($entity, Constraint $constraint) {
    $term_storage = $this->entityTypeManager->getStorage($entity->getEntityTypeId());
    assert($term_storage instanceof TermStorageInterface);

    // Newly created entities should be able to specify a parent.     if ($entity && $entity->isNew()) {
      return;
    }

    $is_pending_revision = !$entity->isDefaultRevision();
    $pending_term_ids = $term_storage->getTermIdsWithPendingRevisions();
    $ancestors = $term_storage->loadAllParents($entity->id());
    $ancestor_is_pending_revision = (bool) array_intersect_key($ancestorsarray_flip($pending_term_ids));

    $new_parents = array_column($entity->parent->getValue(), 'target_id');
    $original_parents = array_keys($term_storage->loadParents($entity->id())) ?: [0];
    if (($is_pending_revision || $ancestor_is_pending_revision) && $new_parents != $original_parents) {
      $this->context->buildViolation($constraint->message)
        ->atPath('parent')
        ->addViolation();
    }

    
Home | Imprint | This part of the site doesn't use cookies.