*/
class AHQ {
+ /**
+ * Given a list of would-be child nodes, combine them under a common root.
+ *
+ * @param array $children
+ * @param string $tag
+ * @return array
+ */
+ public static function makeRoot($children, $tag = 'placeholder') {
+ return [
+ '#tag' => $tag,
+ '#children' => $children,
+ ];
+ }
+
/**
* Returns all tags with a certain tag name, e.g. 'af-entity'
*
* Parsed summary of the entities used in a given form.
*/
public static function create($layout) {
- $root = [
- '#tag' => 'root',
- '#children' => $layout,
- ];
+ $root = AHQ::makeRoot($layout);
$entities = array_column(AHQ::getTags($root, 'af-entity'), NULL, 'name');
foreach (array_keys($entities) as $entity) {
$entities[$entity]['fields'] = [];