add Parent and Parents functions

This commit is contained in:
Isaac Connor
2018-03-01 19:23:03 -08:00
parent 9af6dc02bc
commit debe4607bc

View File

@@ -288,6 +288,23 @@ $group_options[$Group->Id()] = str_repeat( ' ', $depth ) . $Group->Name();
return $monitor_id;
}
public function Parent( ) {
if ( $this->{'ParentId'} ) {
return new Group($this->{'ParentId'});
}
return null;
}
public function Parents() {
$Parents = array();
$Parent = $this->Parent();
while( $Parent ) {
array_unshift($Parents, $Parent);
$Parent = $Parent->Parent();
}
return $Parents;
}
} # end class Group