You are here

protected function EntityReferenceAdminTest::getAllOptionsList in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/field/src/Tests/EntityReference/EntityReferenceAdminTest.php \Drupal\field\Tests\EntityReference\EntityReferenceAdminTest::getAllOptionsList()

Extracts all options from a select element.

Parameters

\SimpleXMLElement $element: The select element field information.

Return value

array An array of option values as strings.

1 call to EntityReferenceAdminTest::getAllOptionsList()
EntityReferenceAdminTest::assertFieldSelectOptions in core/modules/field/src/Tests/EntityReference/EntityReferenceAdminTest.php
Checks if a select element contains the specified options.

File

core/modules/field/src/Tests/EntityReference/EntityReferenceAdminTest.php, line 456
Contains \Drupal\field\Tests\EntityReference\EntityReferenceAdminTest.

Class

EntityReferenceAdminTest
Tests for the administrative UI.

Namespace

Drupal\field\Tests\EntityReference

Code

protected function getAllOptionsList(\SimpleXMLElement $element) {
  $options = array();

  // Add all options items.
  foreach ($element->option as $option) {
    $options[] = (string) $option['value'];
  }

  // Loops trough all the option groups
  foreach ($element->optgroup as $optgroup) {
    $options = array_merge($this
      ->getAllOptionsList($optgroup), $options);
  }
  return $options;
}