Skip to content

Commit

Permalink
Merge pull request #3 from pjaudiomv/master
Browse files Browse the repository at this point in the history
add ability to include parent service body in list when specifiying p…
  • Loading branch information
pjaudiomv authored Nov 24, 2018
2 parents 50fdf78 + 4154321 commit fbae913
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[*.php]
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit fbae913

Please sign in to comment.