19declare(strict_types=1);
49 private readonly DataFactory
$data =
new DataFactory(),
60 return $this->data->text()->markdown()->simpleDocument(
61 "Deletes a file object, exactly like a deletion in the user interface.\n\n"
62 .
"If the trash of the installation is enabled, the object is moved there and can be "
63 .
"restored by an administrator; otherwise it is removed for good. `in_trash` tells which "
64 .
"of the two happened. The user needs the permission to delete the object."
72 'ref_id' =>
$f->numeric(
'File',
'Reference id of the file object.')
74 ->withDedicatedName(
'ref_id'),
82 $text = $this->data->text()->markdown();
85 $text->simpleDocument(
'What has been deleted.'),
87 'ref_id' =>
$f->int(
$text->simpleDocument(
'Reference id of the deleted object.')),
88 'title' =>
$f->string(
$text->simpleDocument(
'Title of the deleted object.')),
89 'in_trash' =>
$f->bool(
$text->simpleDocument(
90 'Whether the object went to the trash and can be restored; false means it is gone for good.'
109 if ($this->
repository->lookupType($ref_id) !==
'file') {
113 return $this->
repository->mayDelete($usr_id, $ref_id,
'file');
123 $entry = $this->
repository->getFileEntry($ref_id);
125 if ($entry ===
null) {
126 throw new \OutOfBoundsException(
"There is no file object {$ref_id}.", 404);
129 $in_trash = $this->
repository->delete($ref_id);
138 InputFactory $input_factory,
140 array $raw_parameters
146 return $this->data->error(
147 new \DomainException(
'You are not allowed to delete this file.', 403)
152 }
catch (\Throwable
$e) {
164 $ref_id = $this->parameter->id($raw_parameters,
'ref_id',
'A file object is required.');
166 return [
'ref_id' => $ref_id];
Basic Implementation for Activities.
This describes some datastructure in terms of standard data structures such as primitives,...
The permission rule the file activities share: a file may only be handled by a user the system knows,...
static isKnownUser(int $usr_id)
What the file activities hand to Data\Factory::error() when something failed: the result only takes e...
Reads the raw parameters of an activity strictly, with the Refinery.
getInputDescription(FieldFactory $f)
isAllowedToPerform(int $usr_id, mixed $parameters)
toParameters(array $raw_parameters)
perform(mixed $parameters)
maybePerformAs(InputFactory $input_factory, int $usr_id, array $raw_parameters)
__construct(private readonly RepositoryProvider $repository, private readonly Parameter $parameter, private readonly DataFactory $data=new DataFactory(),)
getOutputDescription(Description\Factory $f)
What a deleting activity answers with: enough to tell the user what is gone, and where it went.
The bits of the repository the file activities need: the tree to check where a file may go and access...
A result encapsulates a value or an error and simplifies the handling of those.