-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added touch icon route * fixed php style
- Loading branch information
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace OCA\NMCTheme\Controller; | ||
|
||
use OC\IntegrityCheck\Helpers\FileAccessHelper; | ||
use OCA\NMCTheme\AppInfo\Application; | ||
use OCP\App\IAppManager; | ||
use OCP\AppFramework\Controller; | ||
use OCP\AppFramework\Http; | ||
use OCP\AppFramework\Http\DataDisplayResponse; | ||
use OCP\AppFramework\Http\Response; | ||
use OCP\IRequest; | ||
|
||
class TouchIconController extends Controller { | ||
/** @var FileAccessHelper */ | ||
private $fileAccessHelper; | ||
|
||
/** @var IAppManager */ | ||
private $appManager; | ||
|
||
public function __construct( | ||
IRequest $request, | ||
FileAccessHelper $fileAccessHelper, | ||
IAppManager $appManager, | ||
) { | ||
parent::__construct(Application::APP_ID, $request); | ||
$this->fileAccessHelper = $fileAccessHelper; | ||
$this->appManager = $appManager; | ||
} | ||
|
||
/** | ||
* Return a 512x512 icon for touch devices | ||
* | ||
* @PublicPage | ||
* @NoCSRFRequired | ||
* | ||
* @param string $app ID of the app | ||
* @return DataDisplayResponse<Http::STATUS_OK, array{Content-Type: 'image/png'}>|FileDisplayResponse<Http::STATUS_OK, array{Content-Type: 'image/x-icon'|'image/png'}>|NotFoundResponse<Http::STATUS_NOT_FOUND, array{}> | ||
* | ||
* 200: Touch icon returned | ||
* 404: Touch icon not found | ||
*/ | ||
public function getTouchIcon(string $app = 'core'): Response { | ||
|
||
$touchIconPath = $this->appManager->getAppPath(Application::APP_ID) . "/img/"; | ||
$iconFile = $this->fileAccessHelper->file_get_contents($touchIconPath . 'favicon-touch.png'); | ||
$response = new DataDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/png']); | ||
$response->cacheFor(86400); | ||
|
||
return $response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters