Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command for registering maps mimetypes #1118

Merged
merged 2 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<commands>
<command>OCA\Maps\Command\RescanPhotos</command>
<command>OCA\Maps\Command\RescanTracks</command>
<command>OCA\Maps\Command\RegisterMimetypes</command>
</commands>
<settings>
<admin>OCA\Maps\Settings\AdminSettings</admin>
Expand Down
56 changes: 56 additions & 0 deletions lib/Command/RegisterMimetypes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

/**
* Nextcloud - maps
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Piotr Bator <prbator@gmail.com>
* @copyright Piotr Bator 2017
*/

namespace OCA\Maps\Command;

use OCA\Maps\Service\MimetypeService;
use OCP\Encryption\IManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputOption;
use OCP\IConfig;

use OCA\Maps\Service\PhotofilesService;

class RegisterMimetypes extends Command {

protected $mimetypeService;

public function __construct(MimetypeService $mimetypeService) {
parent::__construct();
$this->mimetypeService = $mimetypeService;
}

/**
* @return void
*/
protected function configure() {
$this->setName('maps:register-mimetypes')
->setDescription('Registers the maps mimetypes for existing and new files.');
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
$this->output = $output;
$output->writeln("Register mimetypes for existing files");
$this->mimetypeService->registerForExistingFiles();
$output->writeln("Register mimetypes for new files");
$this->mimetypeService->registerForNewFiles();
return 0;
}
}