2017-02-09 12:56:42 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @copyright Copyright (c) 2017 Julius Härtl <jus@bitgrid.net>
|
|
|
|
*
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Julius Haertl <jus@bitgrid.net>
|
2017-02-09 12:56:42 +03:00
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
2017-11-06 17:56:42 +03:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
2017-02-09 12:56:42 +03:00
|
|
|
*
|
2017-11-06 17:56:42 +03:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
2017-02-09 12:56:42 +03:00
|
|
|
*
|
2017-11-06 17:56:42 +03:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2017-02-09 12:56:42 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
namespace OCA\Theming\Migration;
|
|
|
|
|
|
|
|
use OCA\Theming\ThemingDefaults;
|
|
|
|
use OCP\Files\IAppData;
|
|
|
|
use OCP\Files\IRootFolder;
|
|
|
|
use OCP\Migration\IRepairStep;
|
|
|
|
use OCP\Migration\IOutput;
|
|
|
|
use OC\Files\Node\File;
|
|
|
|
use OCP\Files\NotFoundException;
|
|
|
|
|
|
|
|
class ThemingImages implements IRepairStep {
|
|
|
|
|
|
|
|
private $appData;
|
|
|
|
private $rootFolder;
|
|
|
|
|
2017-02-09 14:08:42 +03:00
|
|
|
public function __construct(IAppData $appData, IRootFolder $rootFolder) {
|
2017-02-09 12:56:42 +03:00
|
|
|
$this->appData = $appData;
|
|
|
|
$this->rootFolder = $rootFolder;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
public function getName() {
|
|
|
|
return 'Move theming files to AppData storage';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
public function run(IOutput $output) {
|
|
|
|
$folder = $this->appData->newFolder("images");
|
|
|
|
/** @var File $file */
|
|
|
|
$file = null;
|
|
|
|
try {
|
|
|
|
$file = $this->rootFolder->get('themedinstancelogo');
|
2017-02-09 14:08:42 +03:00
|
|
|
$logo = $folder->newFile('logo');
|
2017-02-09 12:56:42 +03:00
|
|
|
$logo->putContent($file->getContent());
|
|
|
|
$file->delete();
|
|
|
|
} catch (NotFoundException $e) {
|
2017-02-09 14:08:42 +03:00
|
|
|
$output->info('No theming logo image to migrate');
|
2017-02-09 12:56:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
$file = $this->rootFolder->get('themedbackgroundlogo');
|
2017-02-09 14:08:42 +03:00
|
|
|
$background = $folder->newFile('background');
|
2017-02-09 12:56:42 +03:00
|
|
|
$background->putContent($file->getContent());
|
|
|
|
$file->delete();
|
|
|
|
} catch (NotFoundException $e) {
|
2017-02-09 14:08:42 +03:00
|
|
|
$output->info('No theming background image to migrate');
|
2017-02-09 12:56:42 +03:00
|
|
|
}
|
|
|
|
}
|
2017-02-09 14:08:42 +03:00
|
|
|
}
|