You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$this->setHelp('This command downloads all attachments, which only have an external URL, to the local filesystem, so that you have an offline copy of the attachments.');
50
+
$this->addOption('--private', null, null, 'If set, the attachments will be downloaded to the private storage.');
51
+
}
52
+
53
+
protectedfunctionexecute(InputInterface$input, OutputInterface$output): int
54
+
{
55
+
$io = newSymfonyStyle($input, $output);
56
+
57
+
$qb = $this->entityManager->createQueryBuilder();
58
+
$qb->select('attachment')
59
+
->from(Attachment::class, 'attachment')
60
+
->where('attachment.external_path IS NOT NULL')
61
+
->andWhere('attachment.external_path != \'\'')
62
+
->andWhere('attachment.internal_path IS NULL');
63
+
64
+
$query = $qb->getQuery();
65
+
$attachments = $query->getResult();
66
+
67
+
if (count($attachments) === 0) {
68
+
$io->success('No attachments with external URL found.');
69
+
return Command::SUCCESS;
70
+
}
71
+
72
+
$io->note('Found ' . count($attachments) . ' attachments with external URL, that will be downloaded.');
73
+
74
+
//If the option --private is set, the attachments will be downloaded to the private storage.
75
+
$private = $input->getOption('private');
76
+
if ($private) {
77
+
if (!$io->confirm('Attachments will be downloaded to the private storage. Continue?')) {
78
+
return Command::SUCCESS;
79
+
}
80
+
} else {
81
+
if (!$io->confirm('Attachments will be downloaded to the public storage, where everybody knowing the correct URL can access it. Continue?')){
0 commit comments