@@ -24,33 +24,33 @@ |
||
24 | 24 | use OCP\IUser; |
25 | 25 | |
26 | 26 | interface ITrashManager extends ITrashBackend { |
27 | - /** |
|
28 | - * Add a backend for the trashbin |
|
29 | - * |
|
30 | - * @param string $storageType |
|
31 | - * @param ITrashBackend $backend |
|
32 | - * @since 15.0.0 |
|
33 | - */ |
|
34 | - public function registerBackend(string $storageType, ITrashBackend $backend); |
|
27 | + /** |
|
28 | + * Add a backend for the trashbin |
|
29 | + * |
|
30 | + * @param string $storageType |
|
31 | + * @param ITrashBackend $backend |
|
32 | + * @since 15.0.0 |
|
33 | + */ |
|
34 | + public function registerBackend(string $storageType, ITrashBackend $backend); |
|
35 | 35 | |
36 | - /** |
|
37 | - * List all trash items in the root of the trashbin |
|
38 | - * |
|
39 | - * @param IUser $user |
|
40 | - * @return ITrashItem[] |
|
41 | - * @since 15.0.0 |
|
42 | - */ |
|
43 | - public function listTrashRoot(IUser $user): array; |
|
36 | + /** |
|
37 | + * List all trash items in the root of the trashbin |
|
38 | + * |
|
39 | + * @param IUser $user |
|
40 | + * @return ITrashItem[] |
|
41 | + * @since 15.0.0 |
|
42 | + */ |
|
43 | + public function listTrashRoot(IUser $user): array; |
|
44 | 44 | |
45 | - /** |
|
46 | - * Temporally prevent files from being moved to the trash |
|
47 | - * |
|
48 | - * @since 15.0.0 |
|
49 | - */ |
|
50 | - public function pauseTrash(); |
|
45 | + /** |
|
46 | + * Temporally prevent files from being moved to the trash |
|
47 | + * |
|
48 | + * @since 15.0.0 |
|
49 | + */ |
|
50 | + public function pauseTrash(); |
|
51 | 51 | |
52 | - /** |
|
53 | - * @since 15.0.0 |
|
54 | - */ |
|
55 | - public function resumeTrash(); |
|
52 | + /** |
|
53 | + * @since 15.0.0 |
|
54 | + */ |
|
55 | + public function resumeTrash(); |
|
56 | 56 | } |
@@ -31,54 +31,54 @@ |
||
31 | 31 | * @since 15.0.0 |
32 | 32 | */ |
33 | 33 | interface ITrashBackend { |
34 | - /** |
|
35 | - * List all trash items in the root of the trashbin |
|
36 | - * |
|
37 | - * @param IUser $user |
|
38 | - * @return ITrashItem[] |
|
39 | - * @since 15.0.0 |
|
40 | - */ |
|
41 | - public function listTrashRoot(IUser $user): array; |
|
34 | + /** |
|
35 | + * List all trash items in the root of the trashbin |
|
36 | + * |
|
37 | + * @param IUser $user |
|
38 | + * @return ITrashItem[] |
|
39 | + * @since 15.0.0 |
|
40 | + */ |
|
41 | + public function listTrashRoot(IUser $user): array; |
|
42 | 42 | |
43 | - /** |
|
44 | - * List all trash items in a subfolder in the trashbin |
|
45 | - * |
|
46 | - * @param ITrashItem $folder |
|
47 | - * @return ITrashItem[] |
|
48 | - * @since 15.0.0 |
|
49 | - */ |
|
50 | - public function listTrashFolder(ITrashItem $folder): array; |
|
43 | + /** |
|
44 | + * List all trash items in a subfolder in the trashbin |
|
45 | + * |
|
46 | + * @param ITrashItem $folder |
|
47 | + * @return ITrashItem[] |
|
48 | + * @since 15.0.0 |
|
49 | + */ |
|
50 | + public function listTrashFolder(ITrashItem $folder): array; |
|
51 | 51 | |
52 | - /** |
|
53 | - * Restore a trashbin item |
|
54 | - * |
|
55 | - * @param ITrashItem $item |
|
56 | - * @since 15.0.0 |
|
57 | - */ |
|
58 | - public function restoreItem(ITrashItem $item); |
|
52 | + /** |
|
53 | + * Restore a trashbin item |
|
54 | + * |
|
55 | + * @param ITrashItem $item |
|
56 | + * @since 15.0.0 |
|
57 | + */ |
|
58 | + public function restoreItem(ITrashItem $item); |
|
59 | 59 | |
60 | - /** |
|
61 | - * Permanently remove an item from trash |
|
62 | - * |
|
63 | - * @param ITrashItem $item |
|
64 | - * @since 15.0.0 |
|
65 | - */ |
|
66 | - public function removeItem(ITrashItem $item); |
|
60 | + /** |
|
61 | + * Permanently remove an item from trash |
|
62 | + * |
|
63 | + * @param ITrashItem $item |
|
64 | + * @since 15.0.0 |
|
65 | + */ |
|
66 | + public function removeItem(ITrashItem $item); |
|
67 | 67 | |
68 | - /** |
|
69 | - * Move a file or folder to trash |
|
70 | - * |
|
71 | - * @param IStorage $storage |
|
72 | - * @param string $internalPath |
|
73 | - * @return boolean whether or not the file was moved to trash, if false then the file should be deleted normally |
|
74 | - * @since 15.0.0 |
|
75 | - */ |
|
76 | - public function moveToTrash(IStorage $storage, string $internalPath): bool; |
|
68 | + /** |
|
69 | + * Move a file or folder to trash |
|
70 | + * |
|
71 | + * @param IStorage $storage |
|
72 | + * @param string $internalPath |
|
73 | + * @return boolean whether or not the file was moved to trash, if false then the file should be deleted normally |
|
74 | + * @since 15.0.0 |
|
75 | + */ |
|
76 | + public function moveToTrash(IStorage $storage, string $internalPath): bool; |
|
77 | 77 | |
78 | - /** |
|
79 | - * @param IUser $user |
|
80 | - * @param int $fileId |
|
81 | - * @return Node|null |
|
82 | - */ |
|
83 | - public function getTrashNodeById(IUser $user, int $fileId); |
|
78 | + /** |
|
79 | + * @param IUser $user |
|
80 | + * @param int $fileId |
|
81 | + * @return Node|null |
|
82 | + */ |
|
83 | + public function getTrashNodeById(IUser $user, int $fileId); |
|
84 | 84 | } |
@@ -67,7 +67,7 @@ |
||
67 | 67 | public function getChildren(): array { |
68 | 68 | $entries = $this->trashManager->listTrashRoot($this->user); |
69 | 69 | |
70 | - $children = array_map(function (ITrashItem $entry) { |
|
70 | + $children = array_map(function(ITrashItem $entry) { |
|
71 | 71 | if ($entry->getType() === FileInfo::TYPE_FOLDER) { |
72 | 72 | return new TrashFolder($this->trashManager, $entry); |
73 | 73 | } |
@@ -20,74 +20,74 @@ |
||
20 | 20 | |
21 | 21 | class TrashRoot implements ICollection { |
22 | 22 | |
23 | - public function __construct( |
|
24 | - private IUser $user, |
|
25 | - private ITrashManager $trashManager, |
|
26 | - ) { |
|
27 | - } |
|
28 | - |
|
29 | - public function delete() { |
|
30 | - if (!ConfigService::getDeleteFromTrashEnabled()) { |
|
31 | - throw new Forbidden('Not allowed to delete items from the trash bin'); |
|
32 | - } |
|
33 | - |
|
34 | - Trashbin::deleteAll(); |
|
35 | - foreach ($this->trashManager->listTrashRoot($this->user) as $trashItem) { |
|
36 | - $this->trashManager->removeItem($trashItem); |
|
37 | - } |
|
38 | - } |
|
39 | - |
|
40 | - public function getName(): string { |
|
41 | - return 'trash'; |
|
42 | - } |
|
43 | - |
|
44 | - public function setName($name) { |
|
45 | - throw new Forbidden('Permission denied to rename this trashbin'); |
|
46 | - } |
|
47 | - |
|
48 | - public function createFile($name, $data = null) { |
|
49 | - throw new Forbidden('Not allowed to create files in the trashbin'); |
|
50 | - } |
|
51 | - |
|
52 | - public function createDirectory($name) { |
|
53 | - throw new Forbidden('Not allowed to create folders in the trashbin'); |
|
54 | - } |
|
55 | - |
|
56 | - public function getChildren(): array { |
|
57 | - $entries = $this->trashManager->listTrashRoot($this->user); |
|
58 | - |
|
59 | - $children = array_map(function (ITrashItem $entry) { |
|
60 | - if ($entry->getType() === FileInfo::TYPE_FOLDER) { |
|
61 | - return new TrashFolder($this->trashManager, $entry); |
|
62 | - } |
|
63 | - return new TrashFile($this->trashManager, $entry); |
|
64 | - }, $entries); |
|
65 | - |
|
66 | - return $children; |
|
67 | - } |
|
68 | - |
|
69 | - public function getChild($name): ITrash { |
|
70 | - $entries = $this->getChildren(); |
|
71 | - |
|
72 | - foreach ($entries as $entry) { |
|
73 | - if ($entry->getName() === $name) { |
|
74 | - return $entry; |
|
75 | - } |
|
76 | - } |
|
77 | - |
|
78 | - throw new NotFound(); |
|
79 | - } |
|
80 | - |
|
81 | - public function childExists($name): bool { |
|
82 | - try { |
|
83 | - $this->getChild($name); |
|
84 | - return true; |
|
85 | - } catch (NotFound $e) { |
|
86 | - return false; |
|
87 | - } |
|
88 | - } |
|
89 | - |
|
90 | - public function getLastModified(): int { |
|
91 | - return 0; |
|
92 | - } |
|
23 | + public function __construct( |
|
24 | + private IUser $user, |
|
25 | + private ITrashManager $trashManager, |
|
26 | + ) { |
|
27 | + } |
|
28 | + |
|
29 | + public function delete() { |
|
30 | + if (!ConfigService::getDeleteFromTrashEnabled()) { |
|
31 | + throw new Forbidden('Not allowed to delete items from the trash bin'); |
|
32 | + } |
|
33 | + |
|
34 | + Trashbin::deleteAll(); |
|
35 | + foreach ($this->trashManager->listTrashRoot($this->user) as $trashItem) { |
|
36 | + $this->trashManager->removeItem($trashItem); |
|
37 | + } |
|
38 | + } |
|
39 | + |
|
40 | + public function getName(): string { |
|
41 | + return 'trash'; |
|
42 | + } |
|
43 | + |
|
44 | + public function setName($name) { |
|
45 | + throw new Forbidden('Permission denied to rename this trashbin'); |
|
46 | + } |
|
47 | + |
|
48 | + public function createFile($name, $data = null) { |
|
49 | + throw new Forbidden('Not allowed to create files in the trashbin'); |
|
50 | + } |
|
51 | + |
|
52 | + public function createDirectory($name) { |
|
53 | + throw new Forbidden('Not allowed to create folders in the trashbin'); |
|
54 | + } |
|
55 | + |
|
56 | + public function getChildren(): array { |
|
57 | + $entries = $this->trashManager->listTrashRoot($this->user); |
|
58 | + |
|
59 | + $children = array_map(function (ITrashItem $entry) { |
|
60 | + if ($entry->getType() === FileInfo::TYPE_FOLDER) { |
|
61 | + return new TrashFolder($this->trashManager, $entry); |
|
62 | + } |
|
63 | + return new TrashFile($this->trashManager, $entry); |
|
64 | + }, $entries); |
|
65 | + |
|
66 | + return $children; |
|
67 | + } |
|
68 | + |
|
69 | + public function getChild($name): ITrash { |
|
70 | + $entries = $this->getChildren(); |
|
71 | + |
|
72 | + foreach ($entries as $entry) { |
|
73 | + if ($entry->getName() === $name) { |
|
74 | + return $entry; |
|
75 | + } |
|
76 | + } |
|
77 | + |
|
78 | + throw new NotFound(); |
|
79 | + } |
|
80 | + |
|
81 | + public function childExists($name): bool { |
|
82 | + try { |
|
83 | + $this->getChild($name); |
|
84 | + return true; |
|
85 | + } catch (NotFound $e) { |
|
86 | + return false; |
|
87 | + } |
|
88 | + } |
|
89 | + |
|
90 | + public function getLastModified(): int { |
|
91 | + return 0; |
|
92 | + } |
|
93 | 93 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | public function getChildren(): array { |
33 | 33 | $entries = $this->trashManager->listTrashFolder($this->data); |
34 | 34 | |
35 | - $children = array_map(function (ITrashItem $entry) { |
|
35 | + $children = array_map(function(ITrashItem $entry) { |
|
36 | 36 | if ($entry->getType() === FileInfo::TYPE_FOLDER) { |
37 | 37 | return new TrashFolderFolder($this->trashManager, $entry); |
38 | 38 | } |
@@ -15,49 +15,49 @@ |
||
15 | 15 | use Sabre\DAV\ICollection; |
16 | 16 | |
17 | 17 | abstract class AbstractTrashFolder extends AbstractTrash implements ICollection, ITrash { |
18 | - public function getChildren(): array { |
|
19 | - $entries = $this->trashManager->listTrashFolder($this->data); |
|
20 | - |
|
21 | - $children = array_map(function (ITrashItem $entry) { |
|
22 | - if ($entry->getType() === FileInfo::TYPE_FOLDER) { |
|
23 | - return new TrashFolderFolder($this->trashManager, $entry); |
|
24 | - } |
|
25 | - return new TrashFolderFile($this->trashManager, $entry); |
|
26 | - }, $entries); |
|
27 | - |
|
28 | - return $children; |
|
29 | - } |
|
30 | - |
|
31 | - public function getChild($name): ITrash { |
|
32 | - $entries = $this->getChildren(); |
|
33 | - |
|
34 | - foreach ($entries as $entry) { |
|
35 | - if ($entry->getName() === $name) { |
|
36 | - return $entry; |
|
37 | - } |
|
38 | - } |
|
39 | - |
|
40 | - throw new NotFound(); |
|
41 | - } |
|
42 | - |
|
43 | - public function childExists($name): bool { |
|
44 | - try { |
|
45 | - $this->getChild($name); |
|
46 | - return true; |
|
47 | - } catch (NotFound $e) { |
|
48 | - return false; |
|
49 | - } |
|
50 | - } |
|
51 | - |
|
52 | - public function setName($name) { |
|
53 | - throw new Forbidden(); |
|
54 | - } |
|
55 | - |
|
56 | - public function createFile($name, $data = null) { |
|
57 | - throw new Forbidden(); |
|
58 | - } |
|
59 | - |
|
60 | - public function createDirectory($name) { |
|
61 | - throw new Forbidden(); |
|
62 | - } |
|
18 | + public function getChildren(): array { |
|
19 | + $entries = $this->trashManager->listTrashFolder($this->data); |
|
20 | + |
|
21 | + $children = array_map(function (ITrashItem $entry) { |
|
22 | + if ($entry->getType() === FileInfo::TYPE_FOLDER) { |
|
23 | + return new TrashFolderFolder($this->trashManager, $entry); |
|
24 | + } |
|
25 | + return new TrashFolderFile($this->trashManager, $entry); |
|
26 | + }, $entries); |
|
27 | + |
|
28 | + return $children; |
|
29 | + } |
|
30 | + |
|
31 | + public function getChild($name): ITrash { |
|
32 | + $entries = $this->getChildren(); |
|
33 | + |
|
34 | + foreach ($entries as $entry) { |
|
35 | + if ($entry->getName() === $name) { |
|
36 | + return $entry; |
|
37 | + } |
|
38 | + } |
|
39 | + |
|
40 | + throw new NotFound(); |
|
41 | + } |
|
42 | + |
|
43 | + public function childExists($name): bool { |
|
44 | + try { |
|
45 | + $this->getChild($name); |
|
46 | + return true; |
|
47 | + } catch (NotFound $e) { |
|
48 | + return false; |
|
49 | + } |
|
50 | + } |
|
51 | + |
|
52 | + public function setName($name) { |
|
53 | + throw new Forbidden(); |
|
54 | + } |
|
55 | + |
|
56 | + public function createFile($name, $data = null) { |
|
57 | + throw new Forbidden(); |
|
58 | + } |
|
59 | + |
|
60 | + public function createDirectory($name) { |
|
61 | + throw new Forbidden(); |
|
62 | + } |
|
63 | 63 | } |
@@ -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) { |
@@ -18,64 +18,64 @@ |
||
18 | 18 | |
19 | 19 | class VersionCollection implements ICollection { |
20 | 20 | |
21 | - public function __construct( |
|
22 | - private File $file, |
|
23 | - private IUser $user, |
|
24 | - private IVersionManager $versionManager, |
|
25 | - ) { |
|
26 | - } |
|
27 | - |
|
28 | - public function createFile($name, $data = null) { |
|
29 | - throw new Forbidden(); |
|
30 | - } |
|
31 | - |
|
32 | - public function createDirectory($name) { |
|
33 | - throw new Forbidden(); |
|
34 | - } |
|
35 | - |
|
36 | - public function getChild($name) { |
|
37 | - /** @var VersionFile[] $versions */ |
|
38 | - $versions = $this->getChildren(); |
|
39 | - |
|
40 | - foreach ($versions as $version) { |
|
41 | - if ($version->getName() === $name) { |
|
42 | - return $version; |
|
43 | - } |
|
44 | - } |
|
45 | - |
|
46 | - throw new NotFound(); |
|
47 | - } |
|
48 | - |
|
49 | - public function getChildren(): array { |
|
50 | - $versions = $this->versionManager->getVersionsForFile($this->user, $this->file); |
|
51 | - |
|
52 | - return array_map(function (IVersion $version) { |
|
53 | - return new VersionFile($version, $this->versionManager); |
|
54 | - }, $versions); |
|
55 | - } |
|
56 | - |
|
57 | - public function childExists($name): bool { |
|
58 | - try { |
|
59 | - $this->getChild($name); |
|
60 | - return true; |
|
61 | - } catch (NotFound $e) { |
|
62 | - return false; |
|
63 | - } |
|
64 | - } |
|
65 | - |
|
66 | - public function delete() { |
|
67 | - throw new Forbidden(); |
|
68 | - } |
|
69 | - |
|
70 | - public function getName(): string { |
|
71 | - return (string)$this->file->getId(); |
|
72 | - } |
|
73 | - |
|
74 | - public function setName($name) { |
|
75 | - throw new Forbidden(); |
|
76 | - } |
|
77 | - |
|
78 | - public function getLastModified(): int { |
|
79 | - return 0; |
|
80 | - } |
|
21 | + public function __construct( |
|
22 | + private File $file, |
|
23 | + private IUser $user, |
|
24 | + private IVersionManager $versionManager, |
|
25 | + ) { |
|
26 | + } |
|
27 | + |
|
28 | + public function createFile($name, $data = null) { |
|
29 | + throw new Forbidden(); |
|
30 | + } |
|
31 | + |
|
32 | + public function createDirectory($name) { |
|
33 | + throw new Forbidden(); |
|
34 | + } |
|
35 | + |
|
36 | + public function getChild($name) { |
|
37 | + /** @var VersionFile[] $versions */ |
|
38 | + $versions = $this->getChildren(); |
|
39 | + |
|
40 | + foreach ($versions as $version) { |
|
41 | + if ($version->getName() === $name) { |
|
42 | + return $version; |
|
43 | + } |
|
44 | + } |
|
45 | + |
|
46 | + throw new NotFound(); |
|
47 | + } |
|
48 | + |
|
49 | + public function getChildren(): array { |
|
50 | + $versions = $this->versionManager->getVersionsForFile($this->user, $this->file); |
|
51 | + |
|
52 | + return array_map(function (IVersion $version) { |
|
53 | + return new VersionFile($version, $this->versionManager); |
|
54 | + }, $versions); |
|
55 | + } |
|
56 | + |
|
57 | + public function childExists($name): bool { |
|
58 | + try { |
|
59 | + $this->getChild($name); |
|
60 | + return true; |
|
61 | + } catch (NotFound $e) { |
|
62 | + return false; |
|
63 | + } |
|
64 | + } |
|
65 | + |
|
66 | + public function delete() { |
|
67 | + throw new Forbidden(); |
|
68 | + } |
|
69 | + |
|
70 | + public function getName(): string { |
|
71 | + return (string)$this->file->getId(); |
|
72 | + } |
|
73 | + |
|
74 | + public function setName($name) { |
|
75 | + throw new Forbidden(); |
|
76 | + } |
|
77 | + |
|
78 | + public function getLastModified(): int { |
|
79 | + return 0; |
|
80 | + } |
|
81 | 81 | } |
@@ -32,18 +32,18 @@ |
||
32 | 32 | |
33 | 33 | class Version1008Date20181105112049 extends SimpleMigrationStep { |
34 | 34 | |
35 | - /** |
|
36 | - * @param IOutput $output |
|
37 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
38 | - * @param array $options |
|
39 | - * @return null|ISchemaWrapper |
|
40 | - */ |
|
41 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
42 | - /** @var ISchemaWrapper $schema */ |
|
43 | - $schema = $schemaClosure(); |
|
44 | - $table = $schema->getTable('calendarsubscriptions'); |
|
45 | - $table->dropColumn('source_copy'); |
|
35 | + /** |
|
36 | + * @param IOutput $output |
|
37 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
38 | + * @param array $options |
|
39 | + * @return null|ISchemaWrapper |
|
40 | + */ |
|
41 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
42 | + /** @var ISchemaWrapper $schema */ |
|
43 | + $schema = $schemaClosure(); |
|
44 | + $table = $schema->getTable('calendarsubscriptions'); |
|
45 | + $table->dropColumn('source_copy'); |
|
46 | 46 | |
47 | - return $schema; |
|
48 | - } |
|
47 | + return $schema; |
|
48 | + } |
|
49 | 49 | } |
@@ -32,18 +32,18 @@ |
||
32 | 32 | |
33 | 33 | class Version1008Date20181105104833 extends SimpleMigrationStep { |
34 | 34 | |
35 | - /** |
|
36 | - * @param IOutput $output |
|
37 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
38 | - * @param array $options |
|
39 | - * @return null|ISchemaWrapper |
|
40 | - */ |
|
41 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
42 | - /** @var ISchemaWrapper $schema */ |
|
43 | - $schema = $schemaClosure(); |
|
44 | - $table = $schema->getTable('calendarsubscriptions'); |
|
45 | - $table->dropColumn('source'); |
|
35 | + /** |
|
36 | + * @param IOutput $output |
|
37 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
38 | + * @param array $options |
|
39 | + * @return null|ISchemaWrapper |
|
40 | + */ |
|
41 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
42 | + /** @var ISchemaWrapper $schema */ |
|
43 | + $schema = $schemaClosure(); |
|
44 | + $table = $schema->getTable('calendarsubscriptions'); |
|
45 | + $table->dropColumn('source'); |
|
46 | 46 | |
47 | - return $schema; |
|
48 | - } |
|
47 | + return $schema; |
|
48 | + } |
|
49 | 49 | } |
@@ -33,27 +33,27 @@ |
||
33 | 33 | class Version1008Date20181114084440 extends SimpleMigrationStep { |
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * @param IOutput $output |
|
38 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
39 | - * @param array $options |
|
40 | - * @return null|ISchemaWrapper |
|
41 | - */ |
|
42 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
43 | - /** @var ISchemaWrapper $schema */ |
|
44 | - $schema = $schemaClosure(); |
|
45 | - |
|
46 | - if ($schema->hasTable('calendarchanges')) { |
|
47 | - $calendarChangesTable = $schema->getTable('calendarchanges'); |
|
48 | - if ($calendarChangesTable->hasIndex('calendarid_calendartype_synctoken')) { |
|
49 | - $calendarChangesTable->dropIndex('calendarid_calendartype_synctoken'); |
|
50 | - } |
|
51 | - |
|
52 | - if (!$calendarChangesTable->hasIndex('calid_type_synctoken')) { |
|
53 | - $calendarChangesTable->addIndex(['calendarid', 'calendartype', 'synctoken'], 'calid_type_synctoken'); |
|
54 | - } |
|
55 | - } |
|
56 | - |
|
57 | - return $schema; |
|
58 | - } |
|
36 | + /** |
|
37 | + * @param IOutput $output |
|
38 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
39 | + * @param array $options |
|
40 | + * @return null|ISchemaWrapper |
|
41 | + */ |
|
42 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
43 | + /** @var ISchemaWrapper $schema */ |
|
44 | + $schema = $schemaClosure(); |
|
45 | + |
|
46 | + if ($schema->hasTable('calendarchanges')) { |
|
47 | + $calendarChangesTable = $schema->getTable('calendarchanges'); |
|
48 | + if ($calendarChangesTable->hasIndex('calendarid_calendartype_synctoken')) { |
|
49 | + $calendarChangesTable->dropIndex('calendarid_calendartype_synctoken'); |
|
50 | + } |
|
51 | + |
|
52 | + if (!$calendarChangesTable->hasIndex('calid_type_synctoken')) { |
|
53 | + $calendarChangesTable->addIndex(['calendarid', 'calendartype', 'synctoken'], 'calid_type_synctoken'); |
|
54 | + } |
|
55 | + } |
|
56 | + |
|
57 | + return $schema; |
|
58 | + } |
|
59 | 59 | } |
@@ -31,68 +31,68 @@ |
||
31 | 31 | |
32 | 32 | class Version010401Date20181207190718 extends SimpleMigrationStep { |
33 | 33 | |
34 | - /** |
|
35 | - * @param IOutput $output |
|
36 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
37 | - * @param array $options |
|
38 | - * @return null|ISchemaWrapper |
|
39 | - */ |
|
40 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
41 | - /** @var ISchemaWrapper $schema */ |
|
42 | - $schema = $schemaClosure(); |
|
34 | + /** |
|
35 | + * @param IOutput $output |
|
36 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
37 | + * @param array $options |
|
38 | + * @return null|ISchemaWrapper |
|
39 | + */ |
|
40 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
41 | + /** @var ISchemaWrapper $schema */ |
|
42 | + $schema = $schemaClosure(); |
|
43 | 43 | |
44 | - if (!$schema->hasTable('oauth2_clients')) { |
|
45 | - $table = $schema->createTable('oauth2_clients'); |
|
46 | - $table->addColumn('id', 'integer', [ |
|
47 | - 'autoincrement' => true, |
|
48 | - 'notnull' => true, |
|
49 | - 'unsigned' => true, |
|
50 | - ]); |
|
51 | - $table->addColumn('name', 'string', [ |
|
52 | - 'notnull' => true, |
|
53 | - 'length' => 64, |
|
54 | - ]); |
|
55 | - $table->addColumn('redirect_uri', 'string', [ |
|
56 | - 'notnull' => true, |
|
57 | - 'length' => 2000, |
|
58 | - ]); |
|
59 | - $table->addColumn('client_identifier', 'string', [ |
|
60 | - 'notnull' => true, |
|
61 | - 'length' => 64, |
|
62 | - ]); |
|
63 | - $table->addColumn('secret', 'string', [ |
|
64 | - 'notnull' => true, |
|
65 | - 'length' => 64, |
|
66 | - ]); |
|
67 | - $table->setPrimaryKey(['id']); |
|
68 | - $table->addIndex(['client_identifier'], 'oauth2_client_id_idx'); |
|
69 | - } |
|
44 | + if (!$schema->hasTable('oauth2_clients')) { |
|
45 | + $table = $schema->createTable('oauth2_clients'); |
|
46 | + $table->addColumn('id', 'integer', [ |
|
47 | + 'autoincrement' => true, |
|
48 | + 'notnull' => true, |
|
49 | + 'unsigned' => true, |
|
50 | + ]); |
|
51 | + $table->addColumn('name', 'string', [ |
|
52 | + 'notnull' => true, |
|
53 | + 'length' => 64, |
|
54 | + ]); |
|
55 | + $table->addColumn('redirect_uri', 'string', [ |
|
56 | + 'notnull' => true, |
|
57 | + 'length' => 2000, |
|
58 | + ]); |
|
59 | + $table->addColumn('client_identifier', 'string', [ |
|
60 | + 'notnull' => true, |
|
61 | + 'length' => 64, |
|
62 | + ]); |
|
63 | + $table->addColumn('secret', 'string', [ |
|
64 | + 'notnull' => true, |
|
65 | + 'length' => 64, |
|
66 | + ]); |
|
67 | + $table->setPrimaryKey(['id']); |
|
68 | + $table->addIndex(['client_identifier'], 'oauth2_client_id_idx'); |
|
69 | + } |
|
70 | 70 | |
71 | - if (!$schema->hasTable('oauth2_access_tokens')) { |
|
72 | - $table = $schema->createTable('oauth2_access_tokens'); |
|
73 | - $table->addColumn('id', 'integer', [ |
|
74 | - 'autoincrement' => true, |
|
75 | - 'notnull' => true, |
|
76 | - 'unsigned' => true, |
|
77 | - ]); |
|
78 | - $table->addColumn('token_id', 'integer', [ |
|
79 | - 'notnull' => true, |
|
80 | - ]); |
|
81 | - $table->addColumn('client_id', 'integer', [ |
|
82 | - 'notnull' => true, |
|
83 | - ]); |
|
84 | - $table->addColumn('hashed_code', 'string', [ |
|
85 | - 'notnull' => true, |
|
86 | - 'length' => 128, |
|
87 | - ]); |
|
88 | - $table->addColumn('encrypted_token', 'string', [ |
|
89 | - 'notnull' => true, |
|
90 | - 'length' => 786, |
|
91 | - ]); |
|
92 | - $table->setPrimaryKey(['id']); |
|
93 | - $table->addUniqueIndex(['hashed_code'], 'oauth2_access_hash_idx'); |
|
94 | - $table->addIndex(['client_id'], 'oauth2_access_client_id_idx'); |
|
95 | - } |
|
96 | - return $schema; |
|
97 | - } |
|
71 | + if (!$schema->hasTable('oauth2_access_tokens')) { |
|
72 | + $table = $schema->createTable('oauth2_access_tokens'); |
|
73 | + $table->addColumn('id', 'integer', [ |
|
74 | + 'autoincrement' => true, |
|
75 | + 'notnull' => true, |
|
76 | + 'unsigned' => true, |
|
77 | + ]); |
|
78 | + $table->addColumn('token_id', 'integer', [ |
|
79 | + 'notnull' => true, |
|
80 | + ]); |
|
81 | + $table->addColumn('client_id', 'integer', [ |
|
82 | + 'notnull' => true, |
|
83 | + ]); |
|
84 | + $table->addColumn('hashed_code', 'string', [ |
|
85 | + 'notnull' => true, |
|
86 | + 'length' => 128, |
|
87 | + ]); |
|
88 | + $table->addColumn('encrypted_token', 'string', [ |
|
89 | + 'notnull' => true, |
|
90 | + 'length' => 786, |
|
91 | + ]); |
|
92 | + $table->setPrimaryKey(['id']); |
|
93 | + $table->addUniqueIndex(['hashed_code'], 'oauth2_access_hash_idx'); |
|
94 | + $table->addIndex(['client_id'], 'oauth2_access_client_id_idx'); |
|
95 | + } |
|
96 | + return $schema; |
|
97 | + } |
|
98 | 98 | } |