function EntityFieldTest::getContainedStrings
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php \Drupal\KernelTests\Core\Entity\EntityFieldTest::getContainedStrings()
- 8.9.x core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php \Drupal\KernelTests\Core\Entity\EntityFieldTest::getContainedStrings()
- 10 core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php \Drupal\KernelTests\Core\Entity\EntityFieldTest::getContainedStrings()
Gets all contained strings recursively.
1 call to EntityFieldTest::getContainedStrings()
- EntityFieldTest::doTestDataStructureInterfaces in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityFieldTest.php - Executes the data structure interfaces tests for the given entity type.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityFieldTest.php, line 631
Class
- EntityFieldTest
- Tests the Entity Field API.
Namespace
Drupal\KernelTests\Core\EntityCode
public function getContainedStrings(TypedDataInterface $wrapper, $depth, array &$strings) : void {
if ($wrapper instanceof StringInterface) {
$strings[] = $wrapper->getValue();
}
// Recurse until a certain depth is reached if possible.
if ($depth < 7) {
if ($wrapper instanceof ListInterface) {
foreach ($wrapper as $item) {
$this->getContainedStrings($item, $depth + 1, $strings);
}
}
elseif ($wrapper instanceof ComplexDataInterface) {
foreach ($wrapper as $property) {
$this->getContainedStrings($property, $depth + 1, $strings);
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.