Update Composer packages
This commit is contained in:
parent
df93324906
commit
45bdef9a3b
378 changed files with 28466 additions and 28852 deletions
|
@ -195,6 +195,33 @@ class ContentLock
|
|||
return $this->kirby()->locks()->set($this->model, $this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the state for the
|
||||
* form buttons in the frontend
|
||||
*/
|
||||
public function state(): ?string
|
||||
{
|
||||
return match (true) {
|
||||
$this->isUnlocked() => 'unlock',
|
||||
$this->isLocked() => 'lock',
|
||||
default => null
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a usable lock array
|
||||
* for the frontend
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'state' => $this->state(),
|
||||
'data' => $this->get()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes current lock and adds lock user to unlock data
|
||||
*
|
||||
|
@ -223,10 +250,7 @@ class ContentLock
|
|||
*/
|
||||
protected function user(): User
|
||||
{
|
||||
if ($user = $this->kirby()->user()) {
|
||||
return $user;
|
||||
}
|
||||
|
||||
throw new PermissionException('No user authenticated.');
|
||||
return $this->kirby()->user() ??
|
||||
throw new PermissionException('No user authenticated.');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue