julienmonnerie/kirby/config/api/routes/lock.php

57 lines
1 KiB
PHP
Raw Normal View History

2022-06-17 17:51:59 +02:00
<?php
/**
* Content Lock Routes
*/
2023-04-14 16:34:06 +02:00
use Kirby\Exception\NotFoundException;
2022-06-17 17:51:59 +02:00
return [
2022-12-19 14:56:05 +01:00
[
'pattern' => '(:all)/lock',
'method' => 'GET',
'action' => function (string $path) {
return [
'lock' => $this->parent($path)->lock()?->toArray() ?? false
];
}
],
2022-08-31 15:02:43 +02:00
[
'pattern' => '(:all)/lock',
'method' => 'PATCH',
'action' => function (string $path) {
2022-12-19 14:56:05 +01:00
return $this->parent($path)->lock()?->create();
2022-08-31 15:02:43 +02:00
}
],
[
'pattern' => '(:all)/lock',
'method' => 'DELETE',
'action' => function (string $path) {
2023-04-14 16:34:06 +02:00
try {
return $this->parent($path)->lock()?->remove();
} catch (NotFoundException) {
return true;
}
2022-08-31 15:02:43 +02:00
}
],
[
'pattern' => '(:all)/unlock',
'method' => 'PATCH',
'action' => function (string $path) {
2022-12-19 14:56:05 +01:00
return $this->parent($path)->lock()?->unlock();
2022-08-31 15:02:43 +02:00
}
],
[
'pattern' => '(:all)/unlock',
'method' => 'DELETE',
'action' => function (string $path) {
2023-04-14 16:34:06 +02:00
try {
return $this->parent($path)->lock()?->resolve();
} catch (NotFoundException) {
return true;
}
2022-08-31 15:02:43 +02:00
}
],
2022-06-17 17:51:59 +02:00
];