Skip to content

Commit

Permalink
Add nullable settings
Browse files Browse the repository at this point in the history
  • Loading branch information
dieter vanhove authored and dieter vanhove committed Aug 23, 2023
1 parent 00efcf3 commit e5be2bf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/controllers/CraftEntryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ protected static function getEntry(CraftEntry $model): CraftElementEntry
return $entry;
}

protected static function applySettings(CraftElementEntry $entry, stdClass $settings): void
protected static function applySettings(CraftElementEntry $entry, ?stdClass $settings): void
{
if (is_null($settings)) {
return;
}

// Set Craft CMS title & slug
if (is_null($entry->id) || $settings->updateTitleAndSlug) {
if (isset($settings->title)) {
Expand Down Expand Up @@ -151,7 +155,7 @@ public static function updateOrCreateEntry(CraftEntry $model): CraftElementEntry
self::saveAssets($entry, $model->assets);
}

self::applySettings($entry, $model->fields->settings);
self::applySettings($entry, $model->fields->settings ?? null);
unset($model->fields->settings);

$entry->setFieldValues(json_decode(json_encode($model->fields), true));
Expand Down

0 comments on commit e5be2bf

Please sign in to comment.