class YamlFormReflectionHelper in YAML Form 8
Helper class for reflection methods.
Hierarchy
- class \Drupal\yamlform\Utility\YamlFormReflectionHelper
Expanded class hierarchy of YamlFormReflectionHelper
2 files declare their use of YamlFormReflectionHelper
File
- src/
Utility/ YamlFormReflectionHelper.php, line 8
Namespace
Drupal\yamlform\UtilityView source
class YamlFormReflectionHelper {
/**
* Get this element's class hierarchy.
*
* @return array
* An array containing this elements class hierarchy.
*/
public static function getParentClasses($object, $base_class_name = '') {
$class = get_class($object);
$parent_classes = [
self::getClassName($class),
];
do {
$parent_class = get_parent_class($class);
$parent_class_name = self::getClassName($parent_class);
$parent_classes[] = $parent_class_name;
$class = $parent_class;
} while ($parent_class_name != $base_class_name && $class);
return array_reverse($parent_classes);
}
/**
* Get a class's name without its namespace.
*
* @param string $class
* A class.
*
* @return string
* The class's name without its namespace.
*/
protected static function getClassName($class) {
$parts = preg_split('#\\\\#', $class);
return end($parts);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
YamlFormReflectionHelper:: |
protected static | function | Get a class's name without its namespace. | |
YamlFormReflectionHelper:: |
public static | function | Get this element's class hierarchy. |