Skip to content

Commit af2d0e1

Browse files
style: run prettier on changed files
1 parent c33f888 commit af2d0e1

File tree

2 files changed

+13
-22
lines changed

2 files changed

+13
-22
lines changed

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core/Model.inc

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -885,16 +885,14 @@ class Model {
885885
# Check for internal objects from all parents
886886
foreach ($parent_modelset->model_objects as $parent_model) {
887887
# Obtain the internal config for
888-
$child_configs = $this->get_config(
889-
"$parent_model->config_path/$parent_model->id/$this->config_path", []
890-
);
888+
$child_configs = $this->get_config("$parent_model->config_path/$parent_model->id/$this->config_path", []);
891889

892890
foreach ($child_configs as $child_id => $child_config) {
893891
# Retain internal object context information needed to reconstruct the Model object later
894892
$internal_objects[] = [
895-
"_parent_model" => $parent_model,
896-
"_id" => $child_id,
897-
"_internal_object" => $child_config,
893+
'_parent_model' => $parent_model,
894+
'_id' => $child_id,
895+
'_internal_object' => $child_config,
898896
];
899897
}
900898
}
@@ -1978,10 +1976,10 @@ class Model {
19781976
foreach ($internal_objects as $internal_id => $internal_object) {
19791977
# For Models with parent Models, the internal object always contains extra context data about
19801978
# the parent Model class. See the get_internal_objects_from_all_parents() method for more information.
1981-
$internal_id = $model->parent_model_class ? $internal_object["_id"] : $internal_id;
1982-
$parent_model = $model->parent_model_class ? $internal_object["_parent_model"] : null;
1979+
$internal_id = $model->parent_model_class ? $internal_object['_id'] : $internal_id;
1980+
$parent_model = $model->parent_model_class ? $internal_object['_parent_model'] : null;
19831981
$parent_id = $parent_model ? $parent_model->id : null;
1984-
$internal_object = $parent_model ? $internal_object["_internal_object"] : $internal_object;
1982+
$internal_object = $parent_model ? $internal_object['_internal_object'] : $internal_object;
19851983

19861984
# Normalize IDs
19871985
$internal_id = is_numeric($internal_id) ? (int) $internal_id : $internal_id;

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core/ModelCache.inc

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ class ModelCache {
9090
* @param string $index_field The field name to index the Model objects by.
9191
* @return array An associative array of indexed Model objects.
9292
*/
93-
public static function index_modelset_by_field(string $model_class, string $index_field): array
94-
{
93+
public static function index_modelset_by_field(string $model_class, string $index_field): array {
9594
# First, check if this Model class has already been indexed by this field
9695
if (isset(self::$index[$model_class][$index_field])) {
9796
return self::$index[$model_class][$index_field];
@@ -122,11 +121,7 @@ class ModelCache {
122121
* @param mixed $index_value The index field value to look up the Model object by
123122
* @return bool True if a cached Model object exists for the specified Model class and index
124123
*/
125-
public static function has_model(
126-
string $model_class,
127-
string $index_field = 'id',
128-
mixed $index_value = null,
129-
): bool {
124+
public static function has_model(string $model_class, string $index_field = 'id', mixed $index_value = null): bool {
130125
# Cache is always a miss if the Model class is not indexed
131126
if (!self::$index[$model_class]) {
132127
return false;
@@ -145,7 +140,7 @@ class ModelCache {
145140
* Caches a Model object in the ModelCache by its index field/value.
146141
* @param Model $model The Model object to cache.
147142
* @param string $index_field The field to index the Model object by. Only used for many enabled Models.
148-
*/
143+
*/
149144
public static function cache_model(Model $model, string $index_field = 'id'): void {
150145
# Determine the Model class of the Model object
151146
$model_class = $model->get_class_fqn();
@@ -183,12 +178,11 @@ class ModelCache {
183178
string $model_class,
184179
string $index_field = 'id',
185180
mixed $index_value = null,
186-
): Model
187-
{
181+
): Model {
188182
if (!self::has_model($model_class, $index_field, $index_value)) {
189183
throw new NotFoundError(
190184
message: "No cached Model found for Model class '$model_class' with " .
191-
"index field '$index_field' and index value '$index_value'.",
185+
"index field '$index_field' and index value '$index_value'.",
192186
response_id: 'MODEL_CACHE_MODEL_NOT_FOUND',
193187
);
194188
}
@@ -205,8 +199,7 @@ class ModelCache {
205199
/**
206200
* Clears the ModelCache of all cached ModelSets and indexed Model objects.
207201
*/
208-
public static function clear(): void
209-
{
202+
public static function clear(): void {
210203
self::$index = [];
211204
self::$cache = [];
212205
}

0 commit comments

Comments
 (0)