Skip to content
Snippets Groups Projects
Unverified Commit 575dc29c authored by Roeland Jago Douma's avatar Roeland Jago Douma
Browse files

Make Appdata static


* Add fileid for simpleroot folders (only internal)

Signed-off-by: default avatarRoeland Jago Douma <roeland@famdouma.nl>
parent 95592ff6
No related branches found
No related tags found
No related merge requests found
<?php
declare(strict_types=1);
/**
* @copyright 2016 Roeland Jago Douma <roeland@famdouma.nl>
*
......@@ -31,6 +32,7 @@ use OC\SystemConfig;
use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OCP\Files\SimpleFS\ISimpleFolder;
class AppData implements IAppData {
......@@ -55,7 +57,7 @@ class AppData implements IAppData {
*/
public function __construct(IRootFolder $rootFolder,
SystemConfig $systemConfig,
$appId) {
string $appId) {
$this->rootFolder = $rootFolder;
$this->config = $systemConfig;
......@@ -66,7 +68,7 @@ class AppData implements IAppData {
* @return Folder
* @throws \RuntimeException
*/
private function getAppDataFolder() {
private function getAppDataFolder(): Folder {
if ($this->folder === null) {
$instanceId = $this->config->getValue('instanceid', null);
if ($instanceId === null) {
......@@ -101,20 +103,20 @@ class AppData implements IAppData {
return $this->folder;
}
public function getFolder($name) {
public function getFolder(string $name): ISimpleFolder {
$node = $this->getAppDataFolder()->get($name);
/** @var Folder $node */
return new SimpleFolder($node);
}
public function newFolder($name) {
public function newFolder(string $name): ISimpleFolder {
$folder = $this->getAppDataFolder()->newFolder($name);
return new SimpleFolder($folder);
}
public function getDirectoryListing() {
public function getDirectoryListing(): array {
$listing = $this->getAppDataFolder()->getDirectoryListing();
$fileListing = array_map(function(Node $folder) {
......@@ -128,4 +130,8 @@ class AppData implements IAppData {
return array_values($fileListing);
}
public function getId(): int {
return $this->getAppDataFolder()->getId();
}
}
<?php
declare(strict_types=1);
/**
* @copyright 2016 Roeland Jago Douma <roeland@famdouma.nl>
*
......@@ -44,7 +45,7 @@ class Factory {
* @param string $appId
* @return AppData
*/
public function get($appId) {
public function get(string $appId): AppData {
return new AppData($this->rootFolder, $this->config, $appId);
}
}
......@@ -42,7 +42,7 @@ interface ISimpleRoot {
* @throws \RuntimeException
* @since 11.0.0
*/
public function getFolder($name);
public function getFolder(string $name): ISimpleFolder;
/**
* Get all the Folders
......@@ -52,7 +52,7 @@ interface ISimpleRoot {
* @throws \RuntimeException
* @since 11.0.0
*/
public function getDirectoryListing();
public function getDirectoryListing(): array;
/**
* Create a new folder named $name
......@@ -63,5 +63,5 @@ interface ISimpleRoot {
* @throws \RuntimeException
* @since 11.0.0
*/
public function newFolder($name);
public function newFolder(string $name): ISimpleFolder;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment