You are here

private function TermMerger::assertAllTermsHaveSameVocabulary in Term Merge 8

Asserts that all terms have the same vocabulary.

Parameters

\Drupal\taxonomy\TermInterface[] $termsToAssert: The array to assert.

1 call to TermMerger::assertAllTermsHaveSameVocabulary()
TermMerger::validateTerms in src/TermMerger.php
Asserts that all passed in terms are valid.

File

src/TermMerger.php, line 127

Class

TermMerger
Implements TermMergerInterface to provide a term merger service.

Namespace

Drupal\term_merge

Code

private function assertAllTermsHaveSameVocabulary(array $termsToAssert) {
  $vocabulary = '';
  foreach ($termsToAssert as $term) {
    if (empty($vocabulary)) {
      $vocabulary = $term
        ->bundle();
    }
    if ($vocabulary !== $term
      ->bundle()) {
      throw new \RuntimeException('Only merges within the same vocabulary are supported');
    }
  }
}