public static function Utility::splitPropertyPath in Search API 8
Splits a property path into two parts along a path separator (:).
The path is split into one part with a single property name, and one part with the complete rest of the property path (which might be empty). Depending on $separate_last the returned single property key will be the first (FALSE) or last (TRUE) property of the path.
Parameters
string $property_path: The property path to split.
bool $separate_last: (optional) If FALSE, separate the first property of the path. By default, the last property is separated from the rest.
string $separator: (optional) The separator to use.
Return value
string[] An array with indexes 0 and 1, 0 containing the first part of the property path and 1 the second. If $separate_last is FALSE, index 0 will always contain a single property name (without any colons) and index 1 might be NULL. If $separate_last is TRUE it's the exact other way round.
12 calls to Utility::splitPropertyPath()
- ContentEntity::getPropertyPathDependencies in src/
Plugin/ search_api/ datasource/ ContentEntity.php - Computes all dependencies of the given property path.
- FieldsHelper::getNewFieldId in src/
Utility/ FieldsHelper.php - Finds a new unique field identifier on the given index.
- FieldsHelper::retrieveNestedProperty in src/
Utility/ FieldsHelper.php - Retrieves a nested property from a list of properties.
- IntegrationTest::addField in tests/
src/ Functional/ IntegrationTest.php - Adds a field for a specific property to the index.
- ReverseEntityReferences::addFieldValues in src/
Plugin/ search_api/ processor/ ReverseEntityReferences.php - Adds the values of properties defined by this processor to the item.
File
- src/
Utility/ Utility.php, line 140
Class
- Utility
- Contains utility methods for the Search API.
Namespace
Drupal\search_api\UtilityCode
public static function splitPropertyPath($property_path, $separate_last = TRUE, $separator = IndexInterface::PROPERTY_PATH_SEPARATOR) {
$function = $separate_last ? 'strrpos' : 'strpos';
$pos = $function($property_path, $separator);
if ($pos !== FALSE) {
return [
substr($property_path, 0, $pos),
substr($property_path, $pos + 1),
];
}
if ($separate_last) {
return [
NULL,
$property_path,
];
}
return [
$property_path,
NULL,
];
}