-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathFindInTrashCommand.php
More file actions
50 lines (40 loc) · 1.47 KB
/
Copy pathFindInTrashCommand.php
File metadata and controls
50 lines (40 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php declare(strict_types=1);
namespace App\Command;
use Ibexa\Contracts\Core\Repository\TrashService;
use Ibexa\Contracts\Core\Repository\Values\Content\Query;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
#[AsCommand(
name: 'doc:find_in_trash',
description: 'Lists content in Trash belonging to the provided content type.'
)]
class FindInTrashCommand extends Command
{
private TrashService $trashService;
public function __construct(TrashService $trashService)
{
$this->trashService = $trashService;
parent::__construct();
}
protected function configure(): void
{
$this
->setDefinition([
new InputArgument('contentTypeId', InputArgument::REQUIRED, 'Content type ID'),
]);
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$contentTypeId = (int) $input->getArgument('contentTypeId');
$query = new Query();
$query->filter = new Query\Criterion\ContentTypeId($contentTypeId);
$results = $this->trashService->findTrashItems($query);
foreach ($results->items as $trashedLocation) {
$output->writeln($trashedLocation->getContentInfo()->name);
}
return self::SUCCESS;
}
}