Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don’t pass kirby as property to models #6072

Merged
merged 6 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
bastianallgeier marked this conversation as resolved.
Show resolved Hide resolved
'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