Php code bump

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2018-07-19 22:46:32 +02:00
parent bfc6fc8e50
commit 37a4d2bbbc
No known key found for this signature in database
GPG key ID: 60C25B8C072916CF
3 changed files with 15 additions and 5 deletions

View file

@ -30,6 +30,7 @@ use OCP\AppFramework\Http\DataDisplayResponse;
use OCP\AppFramework\Http\NotFoundResponse;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Files\NotFoundException;
use OCP\App\IAppManager;
use OCP\IRequest;
class SvgController extends Controller {
@ -40,13 +41,18 @@ class SvgController extends Controller {
/** @var ITimeFactory */
protected $timeFactory;
/** @var IAppManager */
protected $appManager;
public function __construct(string $appName,
IRequest $request,
ITimeFactory $timeFactory) {
ITimeFactory $timeFactory,
IAppManager $appManager) {
parent::__construct($appName, $request);
$this->serverRoot = \OC::$SERVERROOT;
$this->timeFactory = $timeFactory;
$this->appManager = $appManager;
}
/**
@ -58,7 +64,7 @@ class SvgController extends Controller {
* @param string $folder
* @param string $fileName
* @param string $color
* @return DataDisplayResponse|NotFoundException
* @return DataDisplayResponse|NotFoundResponse
*/
public function getSvgFromCore(string $folder, string $fileName, string $color = 'ffffff') {
$path = $this->serverRoot . "/core/img/$folder/$fileName.svg";
@ -74,7 +80,7 @@ class SvgController extends Controller {
* @param string $app
* @param string $fileName
* @param string $color
* @return DataDisplayResponse|NotFoundException
* @return DataDisplayResponse|NotFoundResponse
*/
public function getSvgFromApp(string $app, string $fileName, string $color = 'ffffff') {
@ -83,7 +89,9 @@ class SvgController extends Controller {
return $this->getSvg($path, $color, $fileName);
}
$appPath = \OC_App::getAppWebPath($app);
$appRootPath = $this->appManager->getAppPath($app);
$appPath = substr($appRootPath, strlen($this->serverRoot));
if (!$appPath) {
return new NotFoundResponse();
}
@ -97,7 +105,7 @@ class SvgController extends Controller {
*
* @param string $path
* @param string $color
* @return DataDisplayResponse|NotFoundException
* @return DataDisplayResponse|NotFoundResponse
*/
private function getSvg(string $path, string $color, string $fileName) {
if (!file_exists($path)) {

View file

@ -1,4 +1,5 @@
<?php
declare (strict_types = 1);
/**
* @copyright Copyright (c) 2018, John Molakvoæ (skjnldsv@protonmail.com)
*

View file

@ -1,4 +1,5 @@
<?php
declare (strict_types = 1);
/**
* @copyright Copyright (c) 2018, John Molakvoæ (skjnldsv@protonmail.com)
*