@@ -32,78 +32,78 @@ |
||
| 32 | 32 | |
| 33 | 33 | class VersionHome implements ICollection { |
| 34 | 34 | |
| 35 | - /** @var array */ |
|
| 36 | - private $principalInfo; |
|
| 37 | - |
|
| 38 | - /** @var IRootFolder */ |
|
| 39 | - private $rootFolder; |
|
| 40 | - |
|
| 41 | - /** @var IUserManager */ |
|
| 42 | - private $userManager; |
|
| 43 | - |
|
| 44 | - /** @var IVersionManager */ |
|
| 45 | - private $versionManager; |
|
| 46 | - |
|
| 47 | - public function __construct(array $principalInfo, IRootFolder $rootFolder, IUserManager $userManager, IVersionManager $versionManager) { |
|
| 48 | - $this->principalInfo = $principalInfo; |
|
| 49 | - $this->rootFolder = $rootFolder; |
|
| 50 | - $this->userManager = $userManager; |
|
| 51 | - $this->versionManager = $versionManager; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - private function getUser() { |
|
| 55 | - list(, $name) = \Sabre\Uri\split($this->principalInfo['uri']); |
|
| 56 | - $user = $this->userManager->get($name); |
|
| 57 | - if (!$user) { |
|
| 58 | - throw new NoUserException(); |
|
| 59 | - } |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - public function delete() { |
|
| 63 | - throw new Forbidden(); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - public function getName(): string { |
|
| 67 | - return $this->getUser()->getUID(); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - public function setName($name) { |
|
| 71 | - throw new Forbidden(); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - public function createFile($name, $data = null) { |
|
| 75 | - throw new Forbidden(); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - public function createDirectory($name) { |
|
| 79 | - throw new Forbidden(); |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - public function getChild($name) { |
|
| 83 | - $user = $this->getUser(); |
|
| 84 | - |
|
| 85 | - if ($name === 'versions') { |
|
| 86 | - return new VersionRoot($user, $this->rootFolder, $this->versionManager); |
|
| 87 | - } |
|
| 88 | - if ($name === 'restore') { |
|
| 89 | - return new RestoreFolder(); |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - public function getChildren() { |
|
| 94 | - $user = $this->getUser(); |
|
| 95 | - |
|
| 96 | - return [ |
|
| 97 | - new VersionRoot($user, $this->rootFolder, $this->versionManager), |
|
| 98 | - new RestoreFolder(), |
|
| 99 | - ]; |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - public function childExists($name) { |
|
| 103 | - return $name === 'versions' || $name === 'restore'; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - public function getLastModified() { |
|
| 107 | - return 0; |
|
| 108 | - } |
|
| 35 | + /** @var array */ |
|
| 36 | + private $principalInfo; |
|
| 37 | + |
|
| 38 | + /** @var IRootFolder */ |
|
| 39 | + private $rootFolder; |
|
| 40 | + |
|
| 41 | + /** @var IUserManager */ |
|
| 42 | + private $userManager; |
|
| 43 | + |
|
| 44 | + /** @var IVersionManager */ |
|
| 45 | + private $versionManager; |
|
| 46 | + |
|
| 47 | + public function __construct(array $principalInfo, IRootFolder $rootFolder, IUserManager $userManager, IVersionManager $versionManager) { |
|
| 48 | + $this->principalInfo = $principalInfo; |
|
| 49 | + $this->rootFolder = $rootFolder; |
|
| 50 | + $this->userManager = $userManager; |
|
| 51 | + $this->versionManager = $versionManager; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + private function getUser() { |
|
| 55 | + list(, $name) = \Sabre\Uri\split($this->principalInfo['uri']); |
|
| 56 | + $user = $this->userManager->get($name); |
|
| 57 | + if (!$user) { |
|
| 58 | + throw new NoUserException(); |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + public function delete() { |
|
| 63 | + throw new Forbidden(); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + public function getName(): string { |
|
| 67 | + return $this->getUser()->getUID(); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + public function setName($name) { |
|
| 71 | + throw new Forbidden(); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + public function createFile($name, $data = null) { |
|
| 75 | + throw new Forbidden(); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + public function createDirectory($name) { |
|
| 79 | + throw new Forbidden(); |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + public function getChild($name) { |
|
| 83 | + $user = $this->getUser(); |
|
| 84 | + |
|
| 85 | + if ($name === 'versions') { |
|
| 86 | + return new VersionRoot($user, $this->rootFolder, $this->versionManager); |
|
| 87 | + } |
|
| 88 | + if ($name === 'restore') { |
|
| 89 | + return new RestoreFolder(); |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + public function getChildren() { |
|
| 94 | + $user = $this->getUser(); |
|
| 95 | + |
|
| 96 | + return [ |
|
| 97 | + new VersionRoot($user, $this->rootFolder, $this->versionManager), |
|
| 98 | + new RestoreFolder(), |
|
| 99 | + ]; |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + public function childExists($name) { |
|
| 103 | + return $name === 'versions' || $name === 'restore'; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + public function getLastModified() { |
|
| 107 | + return 0; |
|
| 108 | + } |
|
| 109 | 109 | } |
@@ -33,52 +33,52 @@ |
||
| 33 | 33 | |
| 34 | 34 | class RootCollection extends AbstractPrincipalCollection { |
| 35 | 35 | |
| 36 | - /** @var IRootFolder */ |
|
| 37 | - private $rootFolder; |
|
| 36 | + /** @var IRootFolder */ |
|
| 37 | + private $rootFolder; |
|
| 38 | 38 | |
| 39 | - /** @var IUserManager */ |
|
| 40 | - private $userManager; |
|
| 39 | + /** @var IUserManager */ |
|
| 40 | + private $userManager; |
|
| 41 | 41 | |
| 42 | - /** @var IVersionManager */ |
|
| 43 | - private $versionManager; |
|
| 42 | + /** @var IVersionManager */ |
|
| 43 | + private $versionManager; |
|
| 44 | 44 | |
| 45 | - public function __construct( |
|
| 46 | - PrincipalBackend\BackendInterface $principalBackend, |
|
| 47 | - IRootFolder $rootFolder, |
|
| 48 | - IConfig $config, |
|
| 49 | - IUserManager $userManager, |
|
| 50 | - IVersionManager $versionManager |
|
| 51 | - ) { |
|
| 52 | - parent::__construct($principalBackend, 'principals/users'); |
|
| 45 | + public function __construct( |
|
| 46 | + PrincipalBackend\BackendInterface $principalBackend, |
|
| 47 | + IRootFolder $rootFolder, |
|
| 48 | + IConfig $config, |
|
| 49 | + IUserManager $userManager, |
|
| 50 | + IVersionManager $versionManager |
|
| 51 | + ) { |
|
| 52 | + parent::__construct($principalBackend, 'principals/users'); |
|
| 53 | 53 | |
| 54 | - $this->rootFolder = $rootFolder; |
|
| 55 | - $this->userManager = $userManager; |
|
| 56 | - $this->versionManager = $versionManager; |
|
| 54 | + $this->rootFolder = $rootFolder; |
|
| 55 | + $this->userManager = $userManager; |
|
| 56 | + $this->versionManager = $versionManager; |
|
| 57 | 57 | |
| 58 | - $this->disableListing = !$config->getSystemValue('debug', false); |
|
| 59 | - } |
|
| 58 | + $this->disableListing = !$config->getSystemValue('debug', false); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * This method returns a node for a principal. |
|
| 63 | - * |
|
| 64 | - * The passed array contains principal information, and is guaranteed to |
|
| 65 | - * at least contain a uri item. Other properties may or may not be |
|
| 66 | - * supplied by the authentication backend. |
|
| 67 | - * |
|
| 68 | - * @param array $principalInfo |
|
| 69 | - * @return INode |
|
| 70 | - */ |
|
| 71 | - public function getChildForPrincipal(array $principalInfo) { |
|
| 72 | - list(, $name) = \Sabre\Uri\split($principalInfo['uri']); |
|
| 73 | - $user = \OC::$server->getUserSession()->getUser(); |
|
| 74 | - if (is_null($user) || $name !== $user->getUID()) { |
|
| 75 | - throw new \Sabre\DAV\Exception\Forbidden(); |
|
| 76 | - } |
|
| 77 | - return new VersionHome($principalInfo, $this->rootFolder, $this->userManager, $this->versionManager); |
|
| 78 | - } |
|
| 61 | + /** |
|
| 62 | + * This method returns a node for a principal. |
|
| 63 | + * |
|
| 64 | + * The passed array contains principal information, and is guaranteed to |
|
| 65 | + * at least contain a uri item. Other properties may or may not be |
|
| 66 | + * supplied by the authentication backend. |
|
| 67 | + * |
|
| 68 | + * @param array $principalInfo |
|
| 69 | + * @return INode |
|
| 70 | + */ |
|
| 71 | + public function getChildForPrincipal(array $principalInfo) { |
|
| 72 | + list(, $name) = \Sabre\Uri\split($principalInfo['uri']); |
|
| 73 | + $user = \OC::$server->getUserSession()->getUser(); |
|
| 74 | + if (is_null($user) || $name !== $user->getUID()) { |
|
| 75 | + throw new \Sabre\DAV\Exception\Forbidden(); |
|
| 76 | + } |
|
| 77 | + return new VersionHome($principalInfo, $this->rootFolder, $this->userManager, $this->versionManager); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - public function getName() { |
|
| 81 | - return 'versions'; |
|
| 82 | - } |
|
| 80 | + public function getName() { |
|
| 81 | + return 'versions'; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | 84 | } |
@@ -33,74 +33,74 @@ |
||
| 33 | 33 | |
| 34 | 34 | class VersionRoot implements ICollection { |
| 35 | 35 | |
| 36 | - /** @var IUser */ |
|
| 37 | - private $user; |
|
| 36 | + /** @var IUser */ |
|
| 37 | + private $user; |
|
| 38 | 38 | |
| 39 | - /** @var IRootFolder */ |
|
| 40 | - private $rootFolder; |
|
| 39 | + /** @var IRootFolder */ |
|
| 40 | + private $rootFolder; |
|
| 41 | 41 | |
| 42 | - /** @var IVersionManager */ |
|
| 43 | - private $versionManager; |
|
| 42 | + /** @var IVersionManager */ |
|
| 43 | + private $versionManager; |
|
| 44 | 44 | |
| 45 | - public function __construct(IUser $user, IRootFolder $rootFolder, IVersionManager $versionManager) { |
|
| 46 | - $this->user = $user; |
|
| 47 | - $this->rootFolder = $rootFolder; |
|
| 48 | - $this->versionManager = $versionManager; |
|
| 49 | - } |
|
| 45 | + public function __construct(IUser $user, IRootFolder $rootFolder, IVersionManager $versionManager) { |
|
| 46 | + $this->user = $user; |
|
| 47 | + $this->rootFolder = $rootFolder; |
|
| 48 | + $this->versionManager = $versionManager; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - public function delete() { |
|
| 52 | - throw new Forbidden(); |
|
| 53 | - } |
|
| 51 | + public function delete() { |
|
| 52 | + throw new Forbidden(); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - public function getName(): string { |
|
| 56 | - return 'versions'; |
|
| 57 | - } |
|
| 55 | + public function getName(): string { |
|
| 56 | + return 'versions'; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - public function setName($name) { |
|
| 60 | - throw new Forbidden(); |
|
| 61 | - } |
|
| 59 | + public function setName($name) { |
|
| 60 | + throw new Forbidden(); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - public function createFile($name, $data = null) { |
|
| 64 | - throw new Forbidden(); |
|
| 65 | - } |
|
| 63 | + public function createFile($name, $data = null) { |
|
| 64 | + throw new Forbidden(); |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - public function createDirectory($name) { |
|
| 68 | - throw new Forbidden(); |
|
| 69 | - } |
|
| 67 | + public function createDirectory($name) { |
|
| 68 | + throw new Forbidden(); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - public function getChild($name) { |
|
| 72 | - $userFolder = $this->rootFolder->getUserFolder($this->user->getUID()); |
|
| 71 | + public function getChild($name) { |
|
| 72 | + $userFolder = $this->rootFolder->getUserFolder($this->user->getUID()); |
|
| 73 | 73 | |
| 74 | - $fileId = (int)$name; |
|
| 75 | - $nodes = $userFolder->getById($fileId); |
|
| 74 | + $fileId = (int)$name; |
|
| 75 | + $nodes = $userFolder->getById($fileId); |
|
| 76 | 76 | |
| 77 | - if ($nodes === []) { |
|
| 78 | - throw new NotFound(); |
|
| 79 | - } |
|
| 77 | + if ($nodes === []) { |
|
| 78 | + throw new NotFound(); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - $node = array_pop($nodes); |
|
| 81 | + $node = array_pop($nodes); |
|
| 82 | 82 | |
| 83 | - if (!$node instanceof File) { |
|
| 84 | - throw new NotFound(); |
|
| 85 | - } |
|
| 83 | + if (!$node instanceof File) { |
|
| 84 | + throw new NotFound(); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - return new VersionCollection($userFolder, $node, $this->user, $this->versionManager); |
|
| 88 | - } |
|
| 87 | + return new VersionCollection($userFolder, $node, $this->user, $this->versionManager); |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - public function getChildren(): array { |
|
| 91 | - return []; |
|
| 92 | - } |
|
| 90 | + public function getChildren(): array { |
|
| 91 | + return []; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - public function childExists($name): bool { |
|
| 95 | - try { |
|
| 96 | - $this->getChild($name); |
|
| 97 | - return true; |
|
| 98 | - } catch (NotFound $e) { |
|
| 99 | - return false; |
|
| 100 | - } |
|
| 101 | - } |
|
| 94 | + public function childExists($name): bool { |
|
| 95 | + try { |
|
| 96 | + $this->getChild($name); |
|
| 97 | + return true; |
|
| 98 | + } catch (NotFound $e) { |
|
| 99 | + return false; |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - public function getLastModified(): int { |
|
| 104 | - return 0; |
|
| 105 | - } |
|
| 103 | + public function getLastModified(): int { |
|
| 104 | + return 0; |
|
| 105 | + } |
|
| 106 | 106 | } |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | public function getChild($name) { |
| 72 | 72 | $userFolder = $this->rootFolder->getUserFolder($this->user->getUID()); |
| 73 | 73 | |
| 74 | - $fileId = (int)$name; |
|
| 74 | + $fileId = (int) $name; |
|
| 75 | 75 | $nodes = $userFolder->getById($fileId); |
| 76 | 76 | |
| 77 | 77 | if ($nodes === []) { |
@@ -32,58 +32,58 @@ |
||
| 32 | 32 | use Sabre\DAV\IFile; |
| 33 | 33 | |
| 34 | 34 | class VersionFile implements IFile { |
| 35 | - /** @var IVersion */ |
|
| 36 | - private $version; |
|
| 35 | + /** @var IVersion */ |
|
| 36 | + private $version; |
|
| 37 | 37 | |
| 38 | - /** @var IVersionManager */ |
|
| 39 | - private $versionManager; |
|
| 38 | + /** @var IVersionManager */ |
|
| 39 | + private $versionManager; |
|
| 40 | 40 | |
| 41 | - public function __construct(IVersion $version, IVersionManager $versionManager) { |
|
| 42 | - $this->version = $version; |
|
| 43 | - $this->versionManager = $versionManager; |
|
| 44 | - } |
|
| 41 | + public function __construct(IVersion $version, IVersionManager $versionManager) { |
|
| 42 | + $this->version = $version; |
|
| 43 | + $this->versionManager = $versionManager; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - public function put($data) { |
|
| 47 | - throw new Forbidden(); |
|
| 48 | - } |
|
| 46 | + public function put($data) { |
|
| 47 | + throw new Forbidden(); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - public function get() { |
|
| 51 | - try { |
|
| 52 | - return $this->versionManager->read($this->version); |
|
| 53 | - } catch (NotFoundException $e) { |
|
| 54 | - throw new NotFound(); |
|
| 55 | - } |
|
| 56 | - } |
|
| 50 | + public function get() { |
|
| 51 | + try { |
|
| 52 | + return $this->versionManager->read($this->version); |
|
| 53 | + } catch (NotFoundException $e) { |
|
| 54 | + throw new NotFound(); |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - public function getContentType(): string { |
|
| 59 | - return $this->version->getMimeType(); |
|
| 60 | - } |
|
| 58 | + public function getContentType(): string { |
|
| 59 | + return $this->version->getMimeType(); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - public function getETag(): string { |
|
| 63 | - return (string)$this->version->getRevisionId(); |
|
| 64 | - } |
|
| 62 | + public function getETag(): string { |
|
| 63 | + return (string)$this->version->getRevisionId(); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - public function getSize(): int { |
|
| 67 | - return $this->version->getSize(); |
|
| 68 | - } |
|
| 66 | + public function getSize(): int { |
|
| 67 | + return $this->version->getSize(); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - public function delete() { |
|
| 71 | - throw new Forbidden(); |
|
| 72 | - } |
|
| 70 | + public function delete() { |
|
| 71 | + throw new Forbidden(); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - public function getName(): string { |
|
| 75 | - return (string)$this->version->getRevisionId(); |
|
| 76 | - } |
|
| 74 | + public function getName(): string { |
|
| 75 | + return (string)$this->version->getRevisionId(); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - public function setName($name) { |
|
| 79 | - throw new Forbidden(); |
|
| 80 | - } |
|
| 78 | + public function setName($name) { |
|
| 79 | + throw new Forbidden(); |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - public function getLastModified(): int { |
|
| 83 | - return $this->version->getTimestamp(); |
|
| 84 | - } |
|
| 82 | + public function getLastModified(): int { |
|
| 83 | + return $this->version->getTimestamp(); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - public function rollBack() { |
|
| 87 | - $this->versionManager->rollback($this->version); |
|
| 88 | - } |
|
| 86 | + public function rollBack() { |
|
| 87 | + $this->versionManager->rollback($this->version); |
|
| 88 | + } |
|
| 89 | 89 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | public function getETag(): string { |
| 63 | - return (string)$this->version->getRevisionId(); |
|
| 63 | + return (string) $this->version->getRevisionId(); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | public function getSize(): int { |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | public function getName(): string { |
| 75 | - return (string)$this->version->getRevisionId(); |
|
| 75 | + return (string) $this->version->getRevisionId(); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | public function setName($name) { |
@@ -35,76 +35,76 @@ |
||
| 35 | 35 | use Sabre\DAV\ICollection; |
| 36 | 36 | |
| 37 | 37 | class VersionCollection implements ICollection { |
| 38 | - /** @var Folder */ |
|
| 39 | - private $userFolder; |
|
| 40 | - |
|
| 41 | - /** @var File */ |
|
| 42 | - private $file; |
|
| 43 | - |
|
| 44 | - /** @var IUser */ |
|
| 45 | - private $user; |
|
| 46 | - |
|
| 47 | - /** @var IVersionManager */ |
|
| 48 | - private $versionManager; |
|
| 49 | - |
|
| 50 | - public function __construct(Folder $userFolder, File $file, IUser $user, IVersionManager $versionManager) { |
|
| 51 | - $this->userFolder = $userFolder; |
|
| 52 | - $this->file = $file; |
|
| 53 | - $this->user = $user; |
|
| 54 | - $this->versionManager = $versionManager; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - public function createFile($name, $data = null) { |
|
| 58 | - throw new Forbidden(); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - public function createDirectory($name) { |
|
| 62 | - throw new Forbidden(); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - public function getChild($name) { |
|
| 66 | - /** @var VersionFile[] $versions */ |
|
| 67 | - $versions = $this->getChildren(); |
|
| 68 | - |
|
| 69 | - foreach ($versions as $version) { |
|
| 70 | - if ($version->getName() === $name) { |
|
| 71 | - return $version; |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - throw new NotFound(); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - public function getChildren(): array { |
|
| 79 | - $versions = $this->versionManager->getVersionsForFile($this->user, $this->file); |
|
| 80 | - |
|
| 81 | - return array_map(function (IVersion $version) { |
|
| 82 | - return new VersionFile($version, $this->versionManager); |
|
| 83 | - }, $versions); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - public function childExists($name): bool { |
|
| 87 | - try { |
|
| 88 | - $this->getChild($name); |
|
| 89 | - return true; |
|
| 90 | - } catch (NotFound $e) { |
|
| 91 | - return false; |
|
| 92 | - } |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - public function delete() { |
|
| 96 | - throw new Forbidden(); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - public function getName(): string { |
|
| 100 | - return (string)$this->file->getId(); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - public function setName($name) { |
|
| 104 | - throw new Forbidden(); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - public function getLastModified(): int { |
|
| 108 | - return 0; |
|
| 109 | - } |
|
| 38 | + /** @var Folder */ |
|
| 39 | + private $userFolder; |
|
| 40 | + |
|
| 41 | + /** @var File */ |
|
| 42 | + private $file; |
|
| 43 | + |
|
| 44 | + /** @var IUser */ |
|
| 45 | + private $user; |
|
| 46 | + |
|
| 47 | + /** @var IVersionManager */ |
|
| 48 | + private $versionManager; |
|
| 49 | + |
|
| 50 | + public function __construct(Folder $userFolder, File $file, IUser $user, IVersionManager $versionManager) { |
|
| 51 | + $this->userFolder = $userFolder; |
|
| 52 | + $this->file = $file; |
|
| 53 | + $this->user = $user; |
|
| 54 | + $this->versionManager = $versionManager; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + public function createFile($name, $data = null) { |
|
| 58 | + throw new Forbidden(); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + public function createDirectory($name) { |
|
| 62 | + throw new Forbidden(); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + public function getChild($name) { |
|
| 66 | + /** @var VersionFile[] $versions */ |
|
| 67 | + $versions = $this->getChildren(); |
|
| 68 | + |
|
| 69 | + foreach ($versions as $version) { |
|
| 70 | + if ($version->getName() === $name) { |
|
| 71 | + return $version; |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + throw new NotFound(); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + public function getChildren(): array { |
|
| 79 | + $versions = $this->versionManager->getVersionsForFile($this->user, $this->file); |
|
| 80 | + |
|
| 81 | + return array_map(function (IVersion $version) { |
|
| 82 | + return new VersionFile($version, $this->versionManager); |
|
| 83 | + }, $versions); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + public function childExists($name): bool { |
|
| 87 | + try { |
|
| 88 | + $this->getChild($name); |
|
| 89 | + return true; |
|
| 90 | + } catch (NotFound $e) { |
|
| 91 | + return false; |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + public function delete() { |
|
| 96 | + throw new Forbidden(); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + public function getName(): string { |
|
| 100 | + return (string)$this->file->getId(); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + public function setName($name) { |
|
| 104 | + throw new Forbidden(); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + public function getLastModified(): int { |
|
| 108 | + return 0; |
|
| 109 | + } |
|
| 110 | 110 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | public function getChildren(): array { |
| 79 | 79 | $versions = $this->versionManager->getVersionsForFile($this->user, $this->file); |
| 80 | 80 | |
| 81 | - return array_map(function (IVersion $version) { |
|
| 81 | + return array_map(function(IVersion $version) { |
|
| 82 | 82 | return new VersionFile($version, $this->versionManager); |
| 83 | 83 | }, $versions); |
| 84 | 84 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | public function getName(): string { |
| 100 | - return (string)$this->file->getId(); |
|
| 100 | + return (string) $this->file->getId(); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | public function setName($name) { |
@@ -6,50 +6,50 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ComposerStaticInitFiles_Versions |
| 8 | 8 | { |
| 9 | - public static $prefixLengthsPsr4 = array ( |
|
| 9 | + public static $prefixLengthsPsr4 = array( |
|
| 10 | 10 | 'O' => |
| 11 | - array ( |
|
| 11 | + array( |
|
| 12 | 12 | 'OCA\\Files_Versions\\' => 19, |
| 13 | 13 | ), |
| 14 | 14 | ); |
| 15 | 15 | |
| 16 | - public static $prefixDirsPsr4 = array ( |
|
| 16 | + public static $prefixDirsPsr4 = array( |
|
| 17 | 17 | 'OCA\\Files_Versions\\' => |
| 18 | - array ( |
|
| 19 | - 0 => __DIR__ . '/..' . '/../lib', |
|
| 18 | + array( |
|
| 19 | + 0 => __DIR__.'/..'.'/../lib', |
|
| 20 | 20 | ), |
| 21 | 21 | ); |
| 22 | 22 | |
| 23 | - public static $classMap = array ( |
|
| 24 | - 'OCA\\Files_Versions\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php', |
|
| 25 | - 'OCA\\Files_Versions\\BackgroundJob\\ExpireVersions' => __DIR__ . '/..' . '/../lib/BackgroundJob/ExpireVersions.php', |
|
| 26 | - 'OCA\\Files_Versions\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php', |
|
| 27 | - 'OCA\\Files_Versions\\Command\\CleanUp' => __DIR__ . '/..' . '/../lib/Command/CleanUp.php', |
|
| 28 | - 'OCA\\Files_Versions\\Command\\Expire' => __DIR__ . '/..' . '/../lib/Command/Expire.php', |
|
| 29 | - 'OCA\\Files_Versions\\Command\\ExpireVersions' => __DIR__ . '/..' . '/../lib/Command/ExpireVersions.php', |
|
| 30 | - 'OCA\\Files_Versions\\Controller\\PreviewController' => __DIR__ . '/..' . '/../lib/Controller/PreviewController.php', |
|
| 31 | - 'OCA\\Files_Versions\\Events\\CreateVersionEvent' => __DIR__ . '/..' . '/../lib/Events/CreateVersionEvent.php', |
|
| 32 | - 'OCA\\Files_Versions\\Expiration' => __DIR__ . '/..' . '/../lib/Expiration.php', |
|
| 33 | - 'OCA\\Files_Versions\\Hooks' => __DIR__ . '/..' . '/../lib/Hooks.php', |
|
| 34 | - 'OCA\\Files_Versions\\Sabre\\RestoreFolder' => __DIR__ . '/..' . '/../lib/Sabre/RestoreFolder.php', |
|
| 35 | - 'OCA\\Files_Versions\\Sabre\\RootCollection' => __DIR__ . '/..' . '/../lib/Sabre/RootCollection.php', |
|
| 36 | - 'OCA\\Files_Versions\\Sabre\\VersionCollection' => __DIR__ . '/..' . '/../lib/Sabre/VersionCollection.php', |
|
| 37 | - 'OCA\\Files_Versions\\Sabre\\VersionFile' => __DIR__ . '/..' . '/../lib/Sabre/VersionFile.php', |
|
| 38 | - 'OCA\\Files_Versions\\Sabre\\VersionHome' => __DIR__ . '/..' . '/../lib/Sabre/VersionHome.php', |
|
| 39 | - 'OCA\\Files_Versions\\Sabre\\VersionRoot' => __DIR__ . '/..' . '/../lib/Sabre/VersionRoot.php', |
|
| 40 | - 'OCA\\Files_Versions\\Storage' => __DIR__ . '/..' . '/../lib/Storage.php', |
|
| 41 | - 'OCA\\Files_Versions\\Versions\\BackendNotFoundException' => __DIR__ . '/..' . '/../lib/Versions/BackendNotFoundException.php', |
|
| 42 | - 'OCA\\Files_Versions\\Versions\\IVersion' => __DIR__ . '/..' . '/../lib/Versions/IVersion.php', |
|
| 43 | - 'OCA\\Files_Versions\\Versions\\IVersionBackend' => __DIR__ . '/..' . '/../lib/Versions/IVersionBackend.php', |
|
| 44 | - 'OCA\\Files_Versions\\Versions\\IVersionManager' => __DIR__ . '/..' . '/../lib/Versions/IVersionManager.php', |
|
| 45 | - 'OCA\\Files_Versions\\Versions\\LegacyVersionsBackend' => __DIR__ . '/..' . '/../lib/Versions/LegacyVersionsBackend.php', |
|
| 46 | - 'OCA\\Files_Versions\\Versions\\Version' => __DIR__ . '/..' . '/../lib/Versions/Version.php', |
|
| 47 | - 'OCA\\Files_Versions\\Versions\\VersionManager' => __DIR__ . '/..' . '/../lib/Versions/VersionManager.php', |
|
| 23 | + public static $classMap = array( |
|
| 24 | + 'OCA\\Files_Versions\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php', |
|
| 25 | + 'OCA\\Files_Versions\\BackgroundJob\\ExpireVersions' => __DIR__.'/..'.'/../lib/BackgroundJob/ExpireVersions.php', |
|
| 26 | + 'OCA\\Files_Versions\\Capabilities' => __DIR__.'/..'.'/../lib/Capabilities.php', |
|
| 27 | + 'OCA\\Files_Versions\\Command\\CleanUp' => __DIR__.'/..'.'/../lib/Command/CleanUp.php', |
|
| 28 | + 'OCA\\Files_Versions\\Command\\Expire' => __DIR__.'/..'.'/../lib/Command/Expire.php', |
|
| 29 | + 'OCA\\Files_Versions\\Command\\ExpireVersions' => __DIR__.'/..'.'/../lib/Command/ExpireVersions.php', |
|
| 30 | + 'OCA\\Files_Versions\\Controller\\PreviewController' => __DIR__.'/..'.'/../lib/Controller/PreviewController.php', |
|
| 31 | + 'OCA\\Files_Versions\\Events\\CreateVersionEvent' => __DIR__.'/..'.'/../lib/Events/CreateVersionEvent.php', |
|
| 32 | + 'OCA\\Files_Versions\\Expiration' => __DIR__.'/..'.'/../lib/Expiration.php', |
|
| 33 | + 'OCA\\Files_Versions\\Hooks' => __DIR__.'/..'.'/../lib/Hooks.php', |
|
| 34 | + 'OCA\\Files_Versions\\Sabre\\RestoreFolder' => __DIR__.'/..'.'/../lib/Sabre/RestoreFolder.php', |
|
| 35 | + 'OCA\\Files_Versions\\Sabre\\RootCollection' => __DIR__.'/..'.'/../lib/Sabre/RootCollection.php', |
|
| 36 | + 'OCA\\Files_Versions\\Sabre\\VersionCollection' => __DIR__.'/..'.'/../lib/Sabre/VersionCollection.php', |
|
| 37 | + 'OCA\\Files_Versions\\Sabre\\VersionFile' => __DIR__.'/..'.'/../lib/Sabre/VersionFile.php', |
|
| 38 | + 'OCA\\Files_Versions\\Sabre\\VersionHome' => __DIR__.'/..'.'/../lib/Sabre/VersionHome.php', |
|
| 39 | + 'OCA\\Files_Versions\\Sabre\\VersionRoot' => __DIR__.'/..'.'/../lib/Sabre/VersionRoot.php', |
|
| 40 | + 'OCA\\Files_Versions\\Storage' => __DIR__.'/..'.'/../lib/Storage.php', |
|
| 41 | + 'OCA\\Files_Versions\\Versions\\BackendNotFoundException' => __DIR__.'/..'.'/../lib/Versions/BackendNotFoundException.php', |
|
| 42 | + 'OCA\\Files_Versions\\Versions\\IVersion' => __DIR__.'/..'.'/../lib/Versions/IVersion.php', |
|
| 43 | + 'OCA\\Files_Versions\\Versions\\IVersionBackend' => __DIR__.'/..'.'/../lib/Versions/IVersionBackend.php', |
|
| 44 | + 'OCA\\Files_Versions\\Versions\\IVersionManager' => __DIR__.'/..'.'/../lib/Versions/IVersionManager.php', |
|
| 45 | + 'OCA\\Files_Versions\\Versions\\LegacyVersionsBackend' => __DIR__.'/..'.'/../lib/Versions/LegacyVersionsBackend.php', |
|
| 46 | + 'OCA\\Files_Versions\\Versions\\Version' => __DIR__.'/..'.'/../lib/Versions/Version.php', |
|
| 47 | + 'OCA\\Files_Versions\\Versions\\VersionManager' => __DIR__.'/..'.'/../lib/Versions/VersionManager.php', |
|
| 48 | 48 | ); |
| 49 | 49 | |
| 50 | 50 | public static function getInitializer(ClassLoader $loader) |
| 51 | 51 | { |
| 52 | - return \Closure::bind(function () use ($loader) { |
|
| 52 | + return \Closure::bind(function() use ($loader) { |
|
| 53 | 53 | $loader->prefixLengthsPsr4 = ComposerStaticInitFiles_Versions::$prefixLengthsPsr4; |
| 54 | 54 | $loader->prefixDirsPsr4 = ComposerStaticInitFiles_Versions::$prefixDirsPsr4; |
| 55 | 55 | $loader->classMap = ComposerStaticInitFiles_Versions::$classMap; |
@@ -6,28 +6,28 @@ |
||
| 6 | 6 | $baseDir = $vendorDir; |
| 7 | 7 | |
| 8 | 8 | return array( |
| 9 | - 'OCA\\Files_Versions\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php', |
|
| 10 | - 'OCA\\Files_Versions\\BackgroundJob\\ExpireVersions' => $baseDir . '/../lib/BackgroundJob/ExpireVersions.php', |
|
| 11 | - 'OCA\\Files_Versions\\Capabilities' => $baseDir . '/../lib/Capabilities.php', |
|
| 12 | - 'OCA\\Files_Versions\\Command\\CleanUp' => $baseDir . '/../lib/Command/CleanUp.php', |
|
| 13 | - 'OCA\\Files_Versions\\Command\\Expire' => $baseDir . '/../lib/Command/Expire.php', |
|
| 14 | - 'OCA\\Files_Versions\\Command\\ExpireVersions' => $baseDir . '/../lib/Command/ExpireVersions.php', |
|
| 15 | - 'OCA\\Files_Versions\\Controller\\PreviewController' => $baseDir . '/../lib/Controller/PreviewController.php', |
|
| 16 | - 'OCA\\Files_Versions\\Events\\CreateVersionEvent' => $baseDir . '/../lib/Events/CreateVersionEvent.php', |
|
| 17 | - 'OCA\\Files_Versions\\Expiration' => $baseDir . '/../lib/Expiration.php', |
|
| 18 | - 'OCA\\Files_Versions\\Hooks' => $baseDir . '/../lib/Hooks.php', |
|
| 19 | - 'OCA\\Files_Versions\\Sabre\\RestoreFolder' => $baseDir . '/../lib/Sabre/RestoreFolder.php', |
|
| 20 | - 'OCA\\Files_Versions\\Sabre\\RootCollection' => $baseDir . '/../lib/Sabre/RootCollection.php', |
|
| 21 | - 'OCA\\Files_Versions\\Sabre\\VersionCollection' => $baseDir . '/../lib/Sabre/VersionCollection.php', |
|
| 22 | - 'OCA\\Files_Versions\\Sabre\\VersionFile' => $baseDir . '/../lib/Sabre/VersionFile.php', |
|
| 23 | - 'OCA\\Files_Versions\\Sabre\\VersionHome' => $baseDir . '/../lib/Sabre/VersionHome.php', |
|
| 24 | - 'OCA\\Files_Versions\\Sabre\\VersionRoot' => $baseDir . '/../lib/Sabre/VersionRoot.php', |
|
| 25 | - 'OCA\\Files_Versions\\Storage' => $baseDir . '/../lib/Storage.php', |
|
| 26 | - 'OCA\\Files_Versions\\Versions\\BackendNotFoundException' => $baseDir . '/../lib/Versions/BackendNotFoundException.php', |
|
| 27 | - 'OCA\\Files_Versions\\Versions\\IVersion' => $baseDir . '/../lib/Versions/IVersion.php', |
|
| 28 | - 'OCA\\Files_Versions\\Versions\\IVersionBackend' => $baseDir . '/../lib/Versions/IVersionBackend.php', |
|
| 29 | - 'OCA\\Files_Versions\\Versions\\IVersionManager' => $baseDir . '/../lib/Versions/IVersionManager.php', |
|
| 30 | - 'OCA\\Files_Versions\\Versions\\LegacyVersionsBackend' => $baseDir . '/../lib/Versions/LegacyVersionsBackend.php', |
|
| 31 | - 'OCA\\Files_Versions\\Versions\\Version' => $baseDir . '/../lib/Versions/Version.php', |
|
| 32 | - 'OCA\\Files_Versions\\Versions\\VersionManager' => $baseDir . '/../lib/Versions/VersionManager.php', |
|
| 9 | + 'OCA\\Files_Versions\\AppInfo\\Application' => $baseDir.'/../lib/AppInfo/Application.php', |
|
| 10 | + 'OCA\\Files_Versions\\BackgroundJob\\ExpireVersions' => $baseDir.'/../lib/BackgroundJob/ExpireVersions.php', |
|
| 11 | + 'OCA\\Files_Versions\\Capabilities' => $baseDir.'/../lib/Capabilities.php', |
|
| 12 | + 'OCA\\Files_Versions\\Command\\CleanUp' => $baseDir.'/../lib/Command/CleanUp.php', |
|
| 13 | + 'OCA\\Files_Versions\\Command\\Expire' => $baseDir.'/../lib/Command/Expire.php', |
|
| 14 | + 'OCA\\Files_Versions\\Command\\ExpireVersions' => $baseDir.'/../lib/Command/ExpireVersions.php', |
|
| 15 | + 'OCA\\Files_Versions\\Controller\\PreviewController' => $baseDir.'/../lib/Controller/PreviewController.php', |
|
| 16 | + 'OCA\\Files_Versions\\Events\\CreateVersionEvent' => $baseDir.'/../lib/Events/CreateVersionEvent.php', |
|
| 17 | + 'OCA\\Files_Versions\\Expiration' => $baseDir.'/../lib/Expiration.php', |
|
| 18 | + 'OCA\\Files_Versions\\Hooks' => $baseDir.'/../lib/Hooks.php', |
|
| 19 | + 'OCA\\Files_Versions\\Sabre\\RestoreFolder' => $baseDir.'/../lib/Sabre/RestoreFolder.php', |
|
| 20 | + 'OCA\\Files_Versions\\Sabre\\RootCollection' => $baseDir.'/../lib/Sabre/RootCollection.php', |
|
| 21 | + 'OCA\\Files_Versions\\Sabre\\VersionCollection' => $baseDir.'/../lib/Sabre/VersionCollection.php', |
|
| 22 | + 'OCA\\Files_Versions\\Sabre\\VersionFile' => $baseDir.'/../lib/Sabre/VersionFile.php', |
|
| 23 | + 'OCA\\Files_Versions\\Sabre\\VersionHome' => $baseDir.'/../lib/Sabre/VersionHome.php', |
|
| 24 | + 'OCA\\Files_Versions\\Sabre\\VersionRoot' => $baseDir.'/../lib/Sabre/VersionRoot.php', |
|
| 25 | + 'OCA\\Files_Versions\\Storage' => $baseDir.'/../lib/Storage.php', |
|
| 26 | + 'OCA\\Files_Versions\\Versions\\BackendNotFoundException' => $baseDir.'/../lib/Versions/BackendNotFoundException.php', |
|
| 27 | + 'OCA\\Files_Versions\\Versions\\IVersion' => $baseDir.'/../lib/Versions/IVersion.php', |
|
| 28 | + 'OCA\\Files_Versions\\Versions\\IVersionBackend' => $baseDir.'/../lib/Versions/IVersionBackend.php', |
|
| 29 | + 'OCA\\Files_Versions\\Versions\\IVersionManager' => $baseDir.'/../lib/Versions/IVersionManager.php', |
|
| 30 | + 'OCA\\Files_Versions\\Versions\\LegacyVersionsBackend' => $baseDir.'/../lib/Versions/LegacyVersionsBackend.php', |
|
| 31 | + 'OCA\\Files_Versions\\Versions\\Version' => $baseDir.'/../lib/Versions/Version.php', |
|
| 32 | + 'OCA\\Files_Versions\\Versions\\VersionManager' => $baseDir.'/../lib/Versions/VersionManager.php', |
|
| 33 | 33 | ); |