Skip to content

Commit f3f3759

Browse files
Decrease action json footprint
In case no options exist don't create an empty option json.
1 parent 9f6bdf7 commit f3f3759

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/Config/Action.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,14 @@ public function getConditions(): array
173173
public function getJsonData(): array
174174
{
175175
$data = [
176-
'action' => $this->action,
177-
'options' => $this->options->getAll(),
176+
'action' => $this->action
178177
];
179178

179+
$options = $this->options->getAll();
180+
if (!empty($options)) {
181+
$data['options'] = $options;
182+
}
183+
180184
$conditions = $this->getConditionJsonData();
181185
if (!empty($conditions)) {
182186
$data['conditions'] = $conditions;

tests/unit/Config/ActionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function testEmptyOptions(): void
100100
$action = new Action('\\Foo\\Bar');
101101
$config = $action->getJsonData();
102102

103-
$this->assertCount(0, $config['options']);
103+
$this->assertCount(1, $config);
104104
}
105105

106106
/**

0 commit comments

Comments
 (0)