Skip to content

Commit

Permalink
Merge pull request #6072 from getkirby/fix/6061-serializable-objects
Browse files Browse the repository at this point in the history
Don’t pass kirby as property to models
  • Loading branch information
distantnative authored Dec 30, 2023
2 parents 2ff14ab + e028d89 commit a130e4a
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 15 deletions.
9 changes: 2 additions & 7 deletions src/Cms/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -1466,9 +1466,7 @@ protected function setRequest(array $request = null): static
protected function setRoles(array $roles = null): static
{
if ($roles !== null) {
$this->roles = Roles::factory($roles, [
'kirby' => $this
]);
$this->roles = Roles::factory($roles);
}

return $this;
Expand All @@ -1482,9 +1480,7 @@ protected function setRoles(array $roles = null): static
protected function setSite(Site|array $site = null): static
{
if (is_array($site) === true) {
$site = new Site($site + [
'kirby' => $this
]);
$site = new Site($site);
}

$this->site = $site;
Expand All @@ -1499,7 +1495,6 @@ public function site(): Site
return $this->site ??= new Site([
'errorPageId' => $this->options['error'] ?? 'error',
'homePageId' => $this->options['home'] ?? 'home',
'kirby' => $this,
'url' => $this->url('index'),
]);
}
Expand Down
5 changes: 1 addition & 4 deletions src/Cms/AppUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ protected function setUser(User|string $user = null): static
protected function setUsers(array $users = null): static
{
if ($users !== null) {
$this->users = Users::factory($users, [
'kirby' => $this
]);
$this->users = Users::factory($users);
}

return $this;
Expand Down Expand Up @@ -128,7 +126,6 @@ public function users(): Users
{
return $this->users ??= Users::load(
$this->root('accounts'),
['kirby' => $this]
);
}
}
2 changes: 0 additions & 2 deletions src/Cms/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,9 @@ public function changeSort(array $files, int $offset = 0): static
public static function factory(array $files, Page|Site|User $parent): static
{
$collection = new static([], $parent);
$kirby = $parent->kirby();

foreach ($files as $props) {
$props['collection'] = $collection;
$props['kirby'] = $kirby;
$props['parent'] = $parent;

$file = File::factory($props);
Expand Down
2 changes: 0 additions & 2 deletions src/Cms/Pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ public static function factory(
): static {
$model ??= App::instance()->site();
$children = new static([], $model);
$kirby = $model->kirby();

if ($model instanceof Page) {
$parent = $model;
Expand All @@ -158,7 +157,6 @@ public static function factory(
}

foreach ($pages as $props) {
$props['kirby'] = $kirby;
$props['parent'] = $parent;
$props['site'] = $site;
$props['isDraft'] = $draft ?? $props['isDraft'] ?? $props['draft'] ?? false;
Expand Down

0 comments on commit a130e4a

Please sign in to comment.