public function FieldHierarchy::add in Corresponding Entity References 7.3
Add an item of any type to the hierarchy.
2 calls to FieldHierarchy::add()
- FieldHierarchy::addChain in field_object/
includes/ FieldHierarchy.inc - Adds an entire field chain to the hierarchy.
- FieldHierarchy::addField in field_object/
includes/ FieldHierarchy.inc - Adds a single field plugin to the hierarchy.
File
- field_object/
includes/ FieldHierarchy.inc, line 43 - Contains the FieldHierarchy class.
Class
- FieldHierarchy
- @file Contains the FieldHierarchy class.
Code
public function add($item_key, $label = NULL, $parent = FieldHierarchy::ROOT) {
if (!array_key_exists($item_key, $this->data)) {
$this->data[$item_key]['label'] = isset($label) ? $label : $item_key;
}
if (!isset($this->data[$parent]['children'])) {
$this->data[$parent]['children'] = array();
}
if (!in_array($item_key, $this->data[$parent]['children'])) {
$this->data[$parent]['children'][] = $item_key;
}
}