Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
fusiondirectory
fusiondirectory-orchestrator
Commits
b34fa9cd
Commit
b34fa9cd
authored
1 month ago
by
Oana-Eliza Alexa
Browse files
Options
Download
Patches
Plain Diff
change to audit
parent
9261ef6e
78-redesign-audit-class
1 merge request
!74
Draft: Resolve "Redesign audit class"
Pipeline
#32373
failed with stages
in 17 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
plugins/tasks/Audit.php
+27
-3
plugins/tasks/Audit.php
with
27 additions
and
3 deletions
+27
-3
plugins/tasks/Audit.php
+
27
−
3
View file @
b34fa9cd
...
@@ -4,11 +4,12 @@ class Audit implements EndpointInterface
...
@@ -4,11 +4,12 @@ class Audit implements EndpointInterface
{
{
private
TaskGateway
$gateway
;
private
TaskGateway
$gateway
;
private
string
$errorMessage
=
'No audit requiring removal'
;
private
string
$errorMessage
;
public
function
__construct
(
TaskGateway
$gateway
)
public
function
__construct
(
TaskGateway
$gateway
)
{
{
$this
->
gateway
=
$gateway
;
$this
->
gateway
=
$gateway
;
$this
->
errorMessage
=
'No audit requiring removal'
;
}
}
/**
/**
...
@@ -48,7 +49,7 @@ class Audit implements EndpointInterface
...
@@ -48,7 +49,7 @@ class Audit implements EndpointInterface
$result
=
$this
->
processAuditDeletion
(
$this
->
gateway
->
getObjectTypeTask
(
'Audit'
));
$result
=
$this
->
processAuditDeletion
(
$this
->
gateway
->
getObjectTypeTask
(
'Audit'
));
// Recursive function to filter out empty arrays at any depth
// Recursive function to filter out empty arrays at any depth
$filteredResults
=
Utils
::
recursiveArrayFilter
(
$result
);
$filteredResults
=
$this
->
recursiveArrayFilter
(
$result
);
if
(
empty
(
$filteredResults
))
{
if
(
empty
(
$filteredResults
))
{
return
[
$this
->
errorMessage
];
return
[
$this
->
errorMessage
];
...
@@ -80,7 +81,7 @@ class Audit implements EndpointInterface
...
@@ -80,7 +81,7 @@ class Audit implements EndpointInterface
* @return array
* @return array
* @throws Exception
* @throws Exception
*/
*/
private
function
processScheduledTask
(
array
$task
):
array
private
function
processScheduledTask
(
array
$task
):
array
{
{
// Retrieve data from the main task.
// Retrieve data from the main task.
$auditMainTask
=
$this
->
getAuditMainTask
(
$task
[
'fdtasksgranularmaster'
][
0
]);
$auditMainTask
=
$this
->
getAuditMainTask
(
$task
[
'fdtasksgranularmaster'
][
0
]);
...
@@ -126,4 +127,27 @@ class Audit implements EndpointInterface
...
@@ -126,4 +127,27 @@ class Audit implements EndpointInterface
return
$audit
;
return
$audit
;
}
}
/**
* @param array $array
* @return array
* Note : Recursively filters out empty values and arrays at any depth.
*/
private
function
recursiveArrayFilter
(
array
$array
):
array
{
// First filter the array for non-empty elements
$filtered
=
array_filter
(
$array
,
function
(
$item
)
{
if
(
is_array
(
$item
))
{
// Recursively filter the sub-array
$item
=
$this
->
recursiveArrayFilter
(
$item
);
// Only retain non-empty arrays
return
!
empty
(
$item
);
}
else
{
// Retain non-empty scalar values
return
!
empty
(
$item
);
}
});
return
$filtered
;
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets