From 4154321c94ca8e349abca7461011043f13a5b5a3 Mon Sep 17 00:00:00 2001 From: pjaudiomv Date: Sat, 24 Nov 2018 14:24:34 -0500 Subject: [PATCH] add ability to include parent service body in list when specifiying parent servicebody --- .editorconfig | 5 +++++ .gitignore | 1 + README.md | 3 +++ index.php | 6 ++++++ 4 files changed, 15 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitignore diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..90fb9ec --- /dev/null +++ b/.editorconfig @@ -0,0 +1,5 @@ +[*.php] +indent_style = space +indent_size = 4 +end_of_line = lf +insert_final_newline = true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/README.md b/README.md index cd939c6..f72ab57 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,9 @@ its now possible to specify a service body parent, this is usefull for service b * static $parent_service_body_id = ''; +When using this feature if you also want to include the parent service body in the list you must add this to your config as well. + +* static $include_parent_service_body_id = true; These will be added as links to main menu if they exist in the config. diff --git a/index.php b/index.php index ff6a163..4aaecf3 100644 --- a/index.php +++ b/index.php @@ -88,6 +88,12 @@ function sortBySubkey(&$array, $subkey, $sortType = SORT_ASC) { $filter_parent_service_body = array_filter( $gsb_array, function ($var) use ($parent_service_body_id) { return ($var['parent_id'] == $parent_service_body_id); }); + if (isset($include_parent_service_body_id)) { + $key = array_search($parent_service_body_id, array_column($gsb_array, 'id')); + $tmp_parent_sb[$key] = $gsb_array[$key]; + $filter_parent_service_body = array_merge($filter_parent_service_body, $tmp_parent_sb); + sortBySubkey($filter_parent_service_body, 'name'); + } // loop begins foreach($filter_parent_service_body as $row_changes_psb) {