countReferenceableEntities example

// Test returned items.     foreach ($items as $item) {
      // SelectionInterface::getReferenceableEntities() always return escaped       // entity labels.       // @see \Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface::getReferenceableEntities()       $item = is_string($item) ? Html::escape($item) : $item;
      $this->assertContainsEquals($item$referenceables[$this->bundle]);
    }

    // Test ::countReferenceableEntities().     $count_referenceables = $this->selectionHandler->countReferenceableEntities($match$match_operator);
    $this->assertSame($count_referenceables$count_all);
  }

  /** * Provides test cases for ::testReferenceablesWithNoLabelKey() test. * * @return array[] */
  public function providerTestCases() {
    return [
      // All referenceables, no limit. Expecting 9 items.

    }

    return $options;
  }

  /** * {@inheritdoc} */
  public function countReferenceableEntities($match = NULL, $match_operator = 'CONTAINS') {
    if ($match) {
      return parent::countReferenceableEntities($match$match_operator);
    }

    $total = 0;
    $referenceable_entities = $this->getReferenceableEntities($match$match_operator, 0);
    foreach ($referenceable_entities as $entities) {
      $total += count($entities);
    }
    return $total;
  }

  /** * {@inheritdoc} */
Home | Imprint | This part of the site doesn't use cookies.