You are here

public static function YamlFormReflectionHelper::getParentClasses in YAML Form 8

Get this element's class hierarchy.

Return value

array An array containing this elements class hierarchy.

2 calls to YamlFormReflectionHelper::getParentClasses()
YamlFormElementBase::getRelatedTypes in src/YamlFormElementBase.php
Get related element types.
YamlFormPluginElementController::index in src/Controller/YamlFormPluginElementController.php

File

src/Utility/YamlFormReflectionHelper.php, line 16

Class

YamlFormReflectionHelper
Helper class for reflection methods.

Namespace

Drupal\yamlform\Utility

Code

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);
}