Passed
Push — master ( 078203...c81798 )
by Joas
14:40 queued 14s
created
apps/user_ldap/lib/Mapping/GroupMapping.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,12 +29,12 @@
 block discarded – undo
29 29
  */
30 30
 class GroupMapping extends AbstractMapping {
31 31
 
32
-	/**
33
-	 * returns the DB table name which holds the mappings
34
-	 * @return string
35
-	 */
36
-	protected function getTableName(bool $includePrefix = true) {
37
-		$p = $includePrefix ? '*PREFIX*' : '';
38
-		return $p . 'ldap_group_mapping';
39
-	}
32
+    /**
33
+     * returns the DB table name which holds the mappings
34
+     * @return string
35
+     */
36
+    protected function getTableName(bool $includePrefix = true) {
37
+        $p = $includePrefix ? '*PREFIX*' : '';
38
+        return $p . 'ldap_group_mapping';
39
+    }
40 40
 }
Please login to merge, or discard this patch.
apps/dav/lib/Upload/UploadFile.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -30,46 +30,46 @@
 block discarded – undo
30 30
 
31 31
 class UploadFile implements IFile {
32 32
 
33
-	/**  @var File */
34
-	private $file;
33
+    /**  @var File */
34
+    private $file;
35 35
 
36
-	public function __construct(File $file) {
37
-		$this->file = $file;
38
-	}
36
+    public function __construct(File $file) {
37
+        $this->file = $file;
38
+    }
39 39
 
40
-	public function put($data) {
41
-		return $this->file->put($data);
42
-	}
40
+    public function put($data) {
41
+        return $this->file->put($data);
42
+    }
43 43
 
44
-	public function get() {
45
-		return $this->file->get();
46
-	}
44
+    public function get() {
45
+        return $this->file->get();
46
+    }
47 47
 
48
-	public function getContentType() {
49
-		return $this->file->getContentType();
50
-	}
48
+    public function getContentType() {
49
+        return $this->file->getContentType();
50
+    }
51 51
 
52
-	public function getETag() {
53
-		return $this->file->getETag();
54
-	}
52
+    public function getETag() {
53
+        return $this->file->getETag();
54
+    }
55 55
 
56
-	public function getSize() {
57
-		return $this->file->getSize();
58
-	}
56
+    public function getSize() {
57
+        return $this->file->getSize();
58
+    }
59 59
 
60
-	public function delete() {
61
-		$this->file->delete();
62
-	}
60
+    public function delete() {
61
+        $this->file->delete();
62
+    }
63 63
 
64
-	public function getName() {
65
-		return $this->file->getName();
66
-	}
64
+    public function getName() {
65
+        return $this->file->getName();
66
+    }
67 67
 
68
-	public function setName($name) {
69
-		$this->file->setName($name);
70
-	}
68
+    public function setName($name) {
69
+        $this->file->setName($name);
70
+    }
71 71
 
72
-	public function getLastModified() {
73
-		return $this->file->getLastModified();
74
-	}
72
+    public function getLastModified() {
73
+        return $this->file->getLastModified();
74
+    }
75 75
 }
Please login to merge, or discard this patch.
apps/dav/lib/Upload/UploadFolder.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -30,68 +30,68 @@
 block discarded – undo
30 30
 
31 31
 class UploadFolder implements ICollection {
32 32
 
33
-	/** @var Directory */
34
-	private $node;
35
-	/** @var CleanupService */
36
-	private $cleanupService;
37
-
38
-	public function __construct(Directory $node, CleanupService $cleanupService) {
39
-		$this->node = $node;
40
-		$this->cleanupService = $cleanupService;
41
-	}
42
-
43
-	public function createFile($name, $data = null) {
44
-		// TODO: verify name - should be a simple number
45
-		$this->node->createFile($name, $data);
46
-	}
47
-
48
-	public function createDirectory($name) {
49
-		throw new Forbidden('Permission denied to create file (filename ' . $name . ')');
50
-	}
51
-
52
-	public function getChild($name) {
53
-		if ($name === '.file') {
54
-			return new FutureFile($this->node, '.file');
55
-		}
56
-		return new UploadFile($this->node->getChild($name));
57
-	}
58
-
59
-	public function getChildren() {
60
-		$tmpChildren = $this->node->getChildren();
61
-
62
-		$children = [];
63
-		$children[] = new FutureFile($this->node, '.file');
64
-
65
-		foreach ($tmpChildren as $child) {
66
-			$children[] = new UploadFile($child);
67
-		}
68
-
69
-		return $children;
70
-	}
71
-
72
-	public function childExists($name) {
73
-		if ($name === '.file') {
74
-			return true;
75
-		}
76
-		return $this->node->childExists($name);
77
-	}
78
-
79
-	public function delete() {
80
-		$this->node->delete();
81
-
82
-		// Background cleanup job is not needed anymore
83
-		$this->cleanupService->removeJob($this->getName());
84
-	}
85
-
86
-	public function getName() {
87
-		return $this->node->getName();
88
-	}
89
-
90
-	public function setName($name) {
91
-		throw new Forbidden('Permission denied to rename this folder');
92
-	}
93
-
94
-	public function getLastModified() {
95
-		return $this->node->getLastModified();
96
-	}
33
+    /** @var Directory */
34
+    private $node;
35
+    /** @var CleanupService */
36
+    private $cleanupService;
37
+
38
+    public function __construct(Directory $node, CleanupService $cleanupService) {
39
+        $this->node = $node;
40
+        $this->cleanupService = $cleanupService;
41
+    }
42
+
43
+    public function createFile($name, $data = null) {
44
+        // TODO: verify name - should be a simple number
45
+        $this->node->createFile($name, $data);
46
+    }
47
+
48
+    public function createDirectory($name) {
49
+        throw new Forbidden('Permission denied to create file (filename ' . $name . ')');
50
+    }
51
+
52
+    public function getChild($name) {
53
+        if ($name === '.file') {
54
+            return new FutureFile($this->node, '.file');
55
+        }
56
+        return new UploadFile($this->node->getChild($name));
57
+    }
58
+
59
+    public function getChildren() {
60
+        $tmpChildren = $this->node->getChildren();
61
+
62
+        $children = [];
63
+        $children[] = new FutureFile($this->node, '.file');
64
+
65
+        foreach ($tmpChildren as $child) {
66
+            $children[] = new UploadFile($child);
67
+        }
68
+
69
+        return $children;
70
+    }
71
+
72
+    public function childExists($name) {
73
+        if ($name === '.file') {
74
+            return true;
75
+        }
76
+        return $this->node->childExists($name);
77
+    }
78
+
79
+    public function delete() {
80
+        $this->node->delete();
81
+
82
+        // Background cleanup job is not needed anymore
83
+        $this->cleanupService->removeJob($this->getName());
84
+    }
85
+
86
+    public function getName() {
87
+        return $this->node->getName();
88
+    }
89
+
90
+    public function setName($name) {
91
+        throw new Forbidden('Permission denied to rename this folder');
92
+    }
93
+
94
+    public function getLastModified() {
95
+        return $this->node->getLastModified();
96
+    }
97 97
 }
Please login to merge, or discard this patch.
apps/dav/lib/Storage/PublicOwnerWrapper.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -29,27 +29,27 @@
 block discarded – undo
29 29
 
30 30
 class PublicOwnerWrapper extends Wrapper {
31 31
 
32
-	/** @var string */
33
-	private $owner;
34
-
35
-	/**
36
-	 * @param array $arguments ['storage' => $storage, 'owner' => $owner]
37
-	 *
38
-	 * $storage: The storage the permissions mask should be applied on
39
-	 * $owner: The owner to use in case no owner is found
40
-	 */
41
-	public function __construct($arguments) {
42
-		parent::__construct($arguments);
43
-		$this->owner = $arguments['owner'];
44
-	}
45
-
46
-	public function getOwner($path) {
47
-		$owner = parent::getOwner($path);
48
-
49
-		if ($owner === null || $owner === false) {
50
-			return $this->owner;
51
-		}
52
-
53
-		return $owner;
54
-	}
32
+    /** @var string */
33
+    private $owner;
34
+
35
+    /**
36
+     * @param array $arguments ['storage' => $storage, 'owner' => $owner]
37
+     *
38
+     * $storage: The storage the permissions mask should be applied on
39
+     * $owner: The owner to use in case no owner is found
40
+     */
41
+    public function __construct($arguments) {
42
+        parent::__construct($arguments);
43
+        $this->owner = $arguments['owner'];
44
+    }
45
+
46
+    public function getOwner($path) {
47
+        $owner = parent::getOwner($path);
48
+
49
+        if ($owner === null || $owner === false) {
50
+            return $this->owner;
51
+        }
52
+
53
+        return $owner;
54
+    }
55 55
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/Services/IAppConfig.php 1 patch
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -31,81 +31,81 @@
 block discarded – undo
31 31
  * @since 20.0.0
32 32
  */
33 33
 interface IAppConfig {
34
-	/**
35
-	 * Get all keys stored for this app
36
-	 *
37
-	 * @return string[] the keys stored for the app
38
-	 * @since 20.0.0
39
-	 */
40
-	public function getAppKeys(): array ;
34
+    /**
35
+     * Get all keys stored for this app
36
+     *
37
+     * @return string[] the keys stored for the app
38
+     * @since 20.0.0
39
+     */
40
+    public function getAppKeys(): array ;
41 41
 
42
-	/**
43
-	 * Writes a new app wide value
44
-	 *
45
-	 * @param string $key the key of the value, under which will be saved
46
-	 * @param string $value the value that should be stored
47
-	 * @return void
48
-	 * @since 20.0.0
49
-	 */
50
-	public function setAppValue(string $key, string $value): void;
42
+    /**
43
+     * Writes a new app wide value
44
+     *
45
+     * @param string $key the key of the value, under which will be saved
46
+     * @param string $value the value that should be stored
47
+     * @return void
48
+     * @since 20.0.0
49
+     */
50
+    public function setAppValue(string $key, string $value): void;
51 51
 
52
-	/**
53
-	 * Looks up an app wide defined value
54
-	 *
55
-	 * @param string $key the key of the value, under which it was saved
56
-	 * @param string $default the default value to be returned if the value isn't set
57
-	 * @return string the saved value
58
-	 * @since 20.0.0
59
-	 */
60
-	public function getAppValue(string $key, string $default = ''): string;
52
+    /**
53
+     * Looks up an app wide defined value
54
+     *
55
+     * @param string $key the key of the value, under which it was saved
56
+     * @param string $default the default value to be returned if the value isn't set
57
+     * @return string the saved value
58
+     * @since 20.0.0
59
+     */
60
+    public function getAppValue(string $key, string $default = ''): string;
61 61
 
62
-	/**
63
-	 * Delete an app wide defined value
64
-	 *
65
-	 * @param string $key the key of the value, under which it was saved
66
-	 * @return void
67
-	 * @since 20.0.0
68
-	 */
69
-	public function deleteAppValue(string $key): void;
62
+    /**
63
+     * Delete an app wide defined value
64
+     *
65
+     * @param string $key the key of the value, under which it was saved
66
+     * @return void
67
+     * @since 20.0.0
68
+     */
69
+    public function deleteAppValue(string $key): void;
70 70
 
71
-	/**
72
-	 * Removes all keys in appconfig belonging to the app
73
-	 *
74
-	 * @return void
75
-	 * @since 20.0.0
76
-	 */
77
-	public function deleteAppValues(): void;
71
+    /**
72
+     * Removes all keys in appconfig belonging to the app
73
+     *
74
+     * @return void
75
+     * @since 20.0.0
76
+     */
77
+    public function deleteAppValues(): void;
78 78
 
79
-	/**
80
-	 * Set a user defined value
81
-	 *
82
-	 * @param string $userId the userId of the user that we want to store the value under
83
-	 * @param string $key the key under which the value is being stored
84
-	 * @param string $value the value that you want to store
85
-	 * @param string $preCondition only update if the config value was previously the value passed as $preCondition
86
-	 * @throws \OCP\PreConditionNotMetException if a precondition is specified and is not met
87
-	 * @throws \UnexpectedValueException when trying to store an unexpected value
88
-	 * @since 20.0.0
89
-	 */
90
-	public function setUserValue(string $userId, string $key, string $value, ?string $preCondition = null): void;
79
+    /**
80
+     * Set a user defined value
81
+     *
82
+     * @param string $userId the userId of the user that we want to store the value under
83
+     * @param string $key the key under which the value is being stored
84
+     * @param string $value the value that you want to store
85
+     * @param string $preCondition only update if the config value was previously the value passed as $preCondition
86
+     * @throws \OCP\PreConditionNotMetException if a precondition is specified and is not met
87
+     * @throws \UnexpectedValueException when trying to store an unexpected value
88
+     * @since 20.0.0
89
+     */
90
+    public function setUserValue(string $userId, string $key, string $value, ?string $preCondition = null): void;
91 91
 
92
-	/**
93
-	 * Shortcut for getting a user defined value
94
-	 *
95
-	 * @param string $userId the userId of the user that we want to store the value under
96
-	 * @param string $key the key under which the value is being stored
97
-	 * @param mixed $default the default value to be returned if the value isn't set
98
-	 * @return string
99
-	 * @since 20.0.0
100
-	 */
101
-	public function getUserValue(string $userId, string $key, string $default = ''): string;
92
+    /**
93
+     * Shortcut for getting a user defined value
94
+     *
95
+     * @param string $userId the userId of the user that we want to store the value under
96
+     * @param string $key the key under which the value is being stored
97
+     * @param mixed $default the default value to be returned if the value isn't set
98
+     * @return string
99
+     * @since 20.0.0
100
+     */
101
+    public function getUserValue(string $userId, string $key, string $default = ''): string;
102 102
 
103
-	/**
104
-	 * Delete a user value
105
-	 *
106
-	 * @param string $userId the userId of the user that we want to store the value under
107
-	 * @param string $key the key under which the value is being stored
108
-	 * @since 20.0.0
109
-	 */
110
-	public function deleteUserValue(string $userId, string $key): void;
103
+    /**
104
+     * Delete a user value
105
+     *
106
+     * @param string $userId the userId of the user that we want to store the value under
107
+     * @param string $key the key under which the value is being stored
108
+     * @since 20.0.0
109
+     */
110
+    public function deleteUserValue(string $userId, string $key): void;
111 111
 }
Please login to merge, or discard this patch.
lib/private/AppFramework/Services/InitialState.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -29,22 +29,22 @@
 block discarded – undo
29 29
 use OCP\IInitialStateService;
30 30
 
31 31
 class InitialState implements IInitialState {
32
-	/** @var IInitialStateService */
33
-	private $state;
32
+    /** @var IInitialStateService */
33
+    private $state;
34 34
 
35
-	/** @var string */
36
-	private $appName;
35
+    /** @var string */
36
+    private $appName;
37 37
 
38
-	public function __construct(IInitialStateService $state, string $appName) {
39
-		$this->state = $state;
40
-		$this->appName = $appName;
41
-	}
38
+    public function __construct(IInitialStateService $state, string $appName) {
39
+        $this->state = $state;
40
+        $this->appName = $appName;
41
+    }
42 42
 
43
-	public function provideInitialState(string $key, $data): void {
44
-		$this->state->provideInitialState($this->appName, $key, $data);
45
-	}
43
+    public function provideInitialState(string $key, $data): void {
44
+        $this->state->provideInitialState($this->appName, $key, $data);
45
+    }
46 46
 
47
-	public function provideLazyInitialState(string $key, \Closure $closure): void {
48
-		$this->state->provideLazyInitialState($this->appName, $key, $closure);
49
-	}
47
+    public function provideLazyInitialState(string $key, \Closure $closure): void {
48
+        $this->state->provideLazyInitialState($this->appName, $key, $closure);
49
+    }
50 50
 }
Please login to merge, or discard this patch.
resources/update-locales.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -25,28 +25,28 @@
 block discarded – undo
25 25
  */
26 26
 
27 27
 if (!extension_loaded('intl')) {
28
-	echo 'Intl extension is required to run this script.';
29
-	exit(1);
28
+    echo 'Intl extension is required to run this script.';
29
+    exit(1);
30 30
 }
31 31
 
32 32
 require '../3rdparty/autoload.php';
33 33
 
34 34
 $locales = array_map(static function (string $localeCode) {
35
-	return [
36
-		'code' => $localeCode,
37
-		'name' => Locale::getDisplayName($localeCode, 'en')
38
-	];
35
+    return [
36
+        'code' => $localeCode,
37
+        'name' => Locale::getDisplayName($localeCode, 'en')
38
+    ];
39 39
 }, ResourceBundle::getLocales(''));
40 40
 
41 41
 $locales = array_filter($locales, static function (array $locale) {
42
-	return is_array(Punic\Data::explodeLocale($locale['code']));
42
+    return is_array(Punic\Data::explodeLocale($locale['code']));
43 43
 });
44 44
 
45 45
 $locales = array_values($locales);
46 46
 
47 47
 if (file_put_contents(__DIR__ . '/locales.json', json_encode($locales, JSON_PRETTY_PRINT)) === false) {
48
-	echo 'Failed to update locales.json';
49
-	exit(1);
48
+    echo 'Failed to update locales.json';
49
+    exit(1);
50 50
 }
51 51
 
52 52
 echo 'Updated locales.json. Don\'t forget to commit the result.';
Please login to merge, or discard this patch.
apps/comments/lib/Capabilities.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -26,11 +26,11 @@
 block discarded – undo
26 26
 use OCP\Capabilities\ICapability;
27 27
 
28 28
 class Capabilities implements ICapability {
29
-	public function getCapabilities(): array {
30
-		return [
31
-			'files' => [
32
-				'comments' => true,
33
-			]
34
-		];
35
-	}
29
+    public function getCapabilities(): array {
30
+        return [
31
+            'files' => [
32
+                'comments' => true,
33
+            ]
34
+        ];
35
+    }
36 36
 }
Please login to merge, or discard this patch.
lib/private/Files/Node/HookConnector.php 1 patch
Indentation   +198 added lines, -198 removed lines patch added patch discarded remove patch
@@ -47,202 +47,202 @@
 block discarded – undo
47 47
 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
48 48
 
49 49
 class HookConnector {
50
-	/** @var IRootFolder */
51
-	private $root;
52
-
53
-	/** @var View */
54
-	private $view;
55
-
56
-	/** @var FileInfo[] */
57
-	private $deleteMetaCache = [];
58
-
59
-	/** @var EventDispatcherInterface */
60
-	private $legacyDispatcher;
61
-
62
-	/** @var IEventDispatcher */
63
-	private $dispatcher;
64
-
65
-	/**
66
-	 * HookConnector constructor.
67
-	 *
68
-	 * @param Root $root
69
-	 * @param View $view
70
-	 */
71
-	public function __construct(
72
-		IRootFolder $root,
73
-		View $view,
74
-		EventDispatcherInterface $legacyDispatcher,
75
-		IEventDispatcher $dispatcher) {
76
-		$this->root = $root;
77
-		$this->view = $view;
78
-		$this->legacyDispatcher = $legacyDispatcher;
79
-		$this->dispatcher = $dispatcher;
80
-	}
81
-
82
-	public function viewToNode() {
83
-		Util::connectHook('OC_Filesystem', 'write', $this, 'write');
84
-		Util::connectHook('OC_Filesystem', 'post_write', $this, 'postWrite');
85
-
86
-		Util::connectHook('OC_Filesystem', 'create', $this, 'create');
87
-		Util::connectHook('OC_Filesystem', 'post_create', $this, 'postCreate');
88
-
89
-		Util::connectHook('OC_Filesystem', 'delete', $this, 'delete');
90
-		Util::connectHook('OC_Filesystem', 'post_delete', $this, 'postDelete');
91
-
92
-		Util::connectHook('OC_Filesystem', 'rename', $this, 'rename');
93
-		Util::connectHook('OC_Filesystem', 'post_rename', $this, 'postRename');
94
-
95
-		Util::connectHook('OC_Filesystem', 'copy', $this, 'copy');
96
-		Util::connectHook('OC_Filesystem', 'post_copy', $this, 'postCopy');
97
-
98
-		Util::connectHook('OC_Filesystem', 'touch', $this, 'touch');
99
-		Util::connectHook('OC_Filesystem', 'post_touch', $this, 'postTouch');
100
-
101
-		Util::connectHook('OC_Filesystem', 'read', $this, 'read');
102
-	}
103
-
104
-	public function write($arguments) {
105
-		$node = $this->getNodeForPath($arguments['path']);
106
-		$this->root->emit('\OC\Files', 'preWrite', [$node]);
107
-		$this->legacyDispatcher->dispatch('\OCP\Files::preWrite', new GenericEvent($node));
108
-
109
-		$event = new BeforeNodeWrittenEvent($node);
110
-		$this->dispatcher->dispatchTyped($event);
111
-	}
112
-
113
-	public function postWrite($arguments) {
114
-		$node = $this->getNodeForPath($arguments['path']);
115
-		$this->root->emit('\OC\Files', 'postWrite', [$node]);
116
-		$this->legacyDispatcher->dispatch('\OCP\Files::postWrite', new GenericEvent($node));
117
-
118
-		$event = new NodeWrittenEvent($node);
119
-		$this->dispatcher->dispatchTyped($event);
120
-	}
121
-
122
-	public function create($arguments) {
123
-		$node = $this->getNodeForPath($arguments['path']);
124
-		$this->root->emit('\OC\Files', 'preCreate', [$node]);
125
-		$this->legacyDispatcher->dispatch('\OCP\Files::preCreate', new GenericEvent($node));
126
-
127
-		$event = new BeforeNodeCreatedEvent($node);
128
-		$this->dispatcher->dispatchTyped($event);
129
-	}
130
-
131
-	public function postCreate($arguments) {
132
-		$node = $this->getNodeForPath($arguments['path']);
133
-		$this->root->emit('\OC\Files', 'postCreate', [$node]);
134
-		$this->legacyDispatcher->dispatch('\OCP\Files::postCreate', new GenericEvent($node));
135
-
136
-		$event = new NodeCreatedEvent($node);
137
-		$this->dispatcher->dispatchTyped($event);
138
-	}
139
-
140
-	public function delete($arguments) {
141
-		$node = $this->getNodeForPath($arguments['path']);
142
-		$this->deleteMetaCache[$node->getPath()] = $node->getFileInfo();
143
-		$this->root->emit('\OC\Files', 'preDelete', [$node]);
144
-		$this->legacyDispatcher->dispatch('\OCP\Files::preDelete', new GenericEvent($node));
145
-
146
-		$event = new BeforeNodeDeletedEvent($node);
147
-		$this->dispatcher->dispatchTyped($event);
148
-	}
149
-
150
-	public function postDelete($arguments) {
151
-		$node = $this->getNodeForPath($arguments['path']);
152
-		unset($this->deleteMetaCache[$node->getPath()]);
153
-		$this->root->emit('\OC\Files', 'postDelete', [$node]);
154
-		$this->legacyDispatcher->dispatch('\OCP\Files::postDelete', new GenericEvent($node));
155
-
156
-		$event = new NodeDeletedEvent($node);
157
-		$this->dispatcher->dispatchTyped($event);
158
-	}
159
-
160
-	public function touch($arguments) {
161
-		$node = $this->getNodeForPath($arguments['path']);
162
-		$this->root->emit('\OC\Files', 'preTouch', [$node]);
163
-		$this->legacyDispatcher->dispatch('\OCP\Files::preTouch', new GenericEvent($node));
164
-
165
-		$event = new BeforeNodeTouchedEvent($node);
166
-		$this->dispatcher->dispatchTyped($event);
167
-	}
168
-
169
-	public function postTouch($arguments) {
170
-		$node = $this->getNodeForPath($arguments['path']);
171
-		$this->root->emit('\OC\Files', 'postTouch', [$node]);
172
-		$this->legacyDispatcher->dispatch('\OCP\Files::postTouch', new GenericEvent($node));
173
-
174
-		$event = new NodeTouchedEvent($node);
175
-		$this->dispatcher->dispatchTyped($event);
176
-	}
177
-
178
-	public function rename($arguments) {
179
-		$source = $this->getNodeForPath($arguments['oldpath']);
180
-		$target = $this->getNodeForPath($arguments['newpath']);
181
-		$this->root->emit('\OC\Files', 'preRename', [$source, $target]);
182
-		$this->legacyDispatcher->dispatch('\OCP\Files::preRename', new GenericEvent([$source, $target]));
183
-
184
-		$event = new BeforeNodeRenamedEvent($source, $target);
185
-		$this->dispatcher->dispatchTyped($event);
186
-	}
187
-
188
-	public function postRename($arguments) {
189
-		$source = $this->getNodeForPath($arguments['oldpath']);
190
-		$target = $this->getNodeForPath($arguments['newpath']);
191
-		$this->root->emit('\OC\Files', 'postRename', [$source, $target]);
192
-		$this->legacyDispatcher->dispatch('\OCP\Files::postRename', new GenericEvent([$source, $target]));
193
-
194
-		$event = new NodeRenamedEvent($source, $target);
195
-		$this->dispatcher->dispatchTyped($event);
196
-	}
197
-
198
-	public function copy($arguments) {
199
-		$source = $this->getNodeForPath($arguments['oldpath']);
200
-		$target = $this->getNodeForPath($arguments['newpath']);
201
-		$this->root->emit('\OC\Files', 'preCopy', [$source, $target]);
202
-		$this->legacyDispatcher->dispatch('\OCP\Files::preCopy', new GenericEvent([$source, $target]));
203
-
204
-		$event = new BeforeNodeCopiedEvent($source, $target);
205
-		$this->dispatcher->dispatchTyped($event);
206
-	}
207
-
208
-	public function postCopy($arguments) {
209
-		$source = $this->getNodeForPath($arguments['oldpath']);
210
-		$target = $this->getNodeForPath($arguments['newpath']);
211
-		$this->root->emit('\OC\Files', 'postCopy', [$source, $target]);
212
-		$this->legacyDispatcher->dispatch('\OCP\Files::postCopy', new GenericEvent([$source, $target]));
213
-
214
-		$event = new NodeCopiedEvent($source, $target);
215
-		$this->dispatcher->dispatchTyped($event);
216
-	}
217
-
218
-	public function read($arguments) {
219
-		$node = $this->getNodeForPath($arguments['path']);
220
-		$this->root->emit('\OC\Files', 'read', [$node]);
221
-		$this->legacyDispatcher->dispatch('\OCP\Files::read', new GenericEvent([$node]));
222
-
223
-		$event = new BeforeNodeReadEvent($node);
224
-		$this->dispatcher->dispatchTyped($event);
225
-	}
226
-
227
-	private function getNodeForPath($path) {
228
-		$info = Filesystem::getView()->getFileInfo($path);
229
-		if (!$info) {
230
-			$fullPath = Filesystem::getView()->getAbsolutePath($path);
231
-			if (isset($this->deleteMetaCache[$fullPath])) {
232
-				$info = $this->deleteMetaCache[$fullPath];
233
-			} else {
234
-				$info = null;
235
-			}
236
-			if (Filesystem::is_dir($path)) {
237
-				return new NonExistingFolder($this->root, $this->view, $fullPath, $info);
238
-			} else {
239
-				return new NonExistingFile($this->root, $this->view, $fullPath, $info);
240
-			}
241
-		}
242
-		if ($info->getType() === FileInfo::TYPE_FILE) {
243
-			return new File($this->root, $this->view, $info->getPath(), $info);
244
-		} else {
245
-			return new Folder($this->root, $this->view, $info->getPath(), $info);
246
-		}
247
-	}
50
+    /** @var IRootFolder */
51
+    private $root;
52
+
53
+    /** @var View */
54
+    private $view;
55
+
56
+    /** @var FileInfo[] */
57
+    private $deleteMetaCache = [];
58
+
59
+    /** @var EventDispatcherInterface */
60
+    private $legacyDispatcher;
61
+
62
+    /** @var IEventDispatcher */
63
+    private $dispatcher;
64
+
65
+    /**
66
+     * HookConnector constructor.
67
+     *
68
+     * @param Root $root
69
+     * @param View $view
70
+     */
71
+    public function __construct(
72
+        IRootFolder $root,
73
+        View $view,
74
+        EventDispatcherInterface $legacyDispatcher,
75
+        IEventDispatcher $dispatcher) {
76
+        $this->root = $root;
77
+        $this->view = $view;
78
+        $this->legacyDispatcher = $legacyDispatcher;
79
+        $this->dispatcher = $dispatcher;
80
+    }
81
+
82
+    public function viewToNode() {
83
+        Util::connectHook('OC_Filesystem', 'write', $this, 'write');
84
+        Util::connectHook('OC_Filesystem', 'post_write', $this, 'postWrite');
85
+
86
+        Util::connectHook('OC_Filesystem', 'create', $this, 'create');
87
+        Util::connectHook('OC_Filesystem', 'post_create', $this, 'postCreate');
88
+
89
+        Util::connectHook('OC_Filesystem', 'delete', $this, 'delete');
90
+        Util::connectHook('OC_Filesystem', 'post_delete', $this, 'postDelete');
91
+
92
+        Util::connectHook('OC_Filesystem', 'rename', $this, 'rename');
93
+        Util::connectHook('OC_Filesystem', 'post_rename', $this, 'postRename');
94
+
95
+        Util::connectHook('OC_Filesystem', 'copy', $this, 'copy');
96
+        Util::connectHook('OC_Filesystem', 'post_copy', $this, 'postCopy');
97
+
98
+        Util::connectHook('OC_Filesystem', 'touch', $this, 'touch');
99
+        Util::connectHook('OC_Filesystem', 'post_touch', $this, 'postTouch');
100
+
101
+        Util::connectHook('OC_Filesystem', 'read', $this, 'read');
102
+    }
103
+
104
+    public function write($arguments) {
105
+        $node = $this->getNodeForPath($arguments['path']);
106
+        $this->root->emit('\OC\Files', 'preWrite', [$node]);
107
+        $this->legacyDispatcher->dispatch('\OCP\Files::preWrite', new GenericEvent($node));
108
+
109
+        $event = new BeforeNodeWrittenEvent($node);
110
+        $this->dispatcher->dispatchTyped($event);
111
+    }
112
+
113
+    public function postWrite($arguments) {
114
+        $node = $this->getNodeForPath($arguments['path']);
115
+        $this->root->emit('\OC\Files', 'postWrite', [$node]);
116
+        $this->legacyDispatcher->dispatch('\OCP\Files::postWrite', new GenericEvent($node));
117
+
118
+        $event = new NodeWrittenEvent($node);
119
+        $this->dispatcher->dispatchTyped($event);
120
+    }
121
+
122
+    public function create($arguments) {
123
+        $node = $this->getNodeForPath($arguments['path']);
124
+        $this->root->emit('\OC\Files', 'preCreate', [$node]);
125
+        $this->legacyDispatcher->dispatch('\OCP\Files::preCreate', new GenericEvent($node));
126
+
127
+        $event = new BeforeNodeCreatedEvent($node);
128
+        $this->dispatcher->dispatchTyped($event);
129
+    }
130
+
131
+    public function postCreate($arguments) {
132
+        $node = $this->getNodeForPath($arguments['path']);
133
+        $this->root->emit('\OC\Files', 'postCreate', [$node]);
134
+        $this->legacyDispatcher->dispatch('\OCP\Files::postCreate', new GenericEvent($node));
135
+
136
+        $event = new NodeCreatedEvent($node);
137
+        $this->dispatcher->dispatchTyped($event);
138
+    }
139
+
140
+    public function delete($arguments) {
141
+        $node = $this->getNodeForPath($arguments['path']);
142
+        $this->deleteMetaCache[$node->getPath()] = $node->getFileInfo();
143
+        $this->root->emit('\OC\Files', 'preDelete', [$node]);
144
+        $this->legacyDispatcher->dispatch('\OCP\Files::preDelete', new GenericEvent($node));
145
+
146
+        $event = new BeforeNodeDeletedEvent($node);
147
+        $this->dispatcher->dispatchTyped($event);
148
+    }
149
+
150
+    public function postDelete($arguments) {
151
+        $node = $this->getNodeForPath($arguments['path']);
152
+        unset($this->deleteMetaCache[$node->getPath()]);
153
+        $this->root->emit('\OC\Files', 'postDelete', [$node]);
154
+        $this->legacyDispatcher->dispatch('\OCP\Files::postDelete', new GenericEvent($node));
155
+
156
+        $event = new NodeDeletedEvent($node);
157
+        $this->dispatcher->dispatchTyped($event);
158
+    }
159
+
160
+    public function touch($arguments) {
161
+        $node = $this->getNodeForPath($arguments['path']);
162
+        $this->root->emit('\OC\Files', 'preTouch', [$node]);
163
+        $this->legacyDispatcher->dispatch('\OCP\Files::preTouch', new GenericEvent($node));
164
+
165
+        $event = new BeforeNodeTouchedEvent($node);
166
+        $this->dispatcher->dispatchTyped($event);
167
+    }
168
+
169
+    public function postTouch($arguments) {
170
+        $node = $this->getNodeForPath($arguments['path']);
171
+        $this->root->emit('\OC\Files', 'postTouch', [$node]);
172
+        $this->legacyDispatcher->dispatch('\OCP\Files::postTouch', new GenericEvent($node));
173
+
174
+        $event = new NodeTouchedEvent($node);
175
+        $this->dispatcher->dispatchTyped($event);
176
+    }
177
+
178
+    public function rename($arguments) {
179
+        $source = $this->getNodeForPath($arguments['oldpath']);
180
+        $target = $this->getNodeForPath($arguments['newpath']);
181
+        $this->root->emit('\OC\Files', 'preRename', [$source, $target]);
182
+        $this->legacyDispatcher->dispatch('\OCP\Files::preRename', new GenericEvent([$source, $target]));
183
+
184
+        $event = new BeforeNodeRenamedEvent($source, $target);
185
+        $this->dispatcher->dispatchTyped($event);
186
+    }
187
+
188
+    public function postRename($arguments) {
189
+        $source = $this->getNodeForPath($arguments['oldpath']);
190
+        $target = $this->getNodeForPath($arguments['newpath']);
191
+        $this->root->emit('\OC\Files', 'postRename', [$source, $target]);
192
+        $this->legacyDispatcher->dispatch('\OCP\Files::postRename', new GenericEvent([$source, $target]));
193
+
194
+        $event = new NodeRenamedEvent($source, $target);
195
+        $this->dispatcher->dispatchTyped($event);
196
+    }
197
+
198
+    public function copy($arguments) {
199
+        $source = $this->getNodeForPath($arguments['oldpath']);
200
+        $target = $this->getNodeForPath($arguments['newpath']);
201
+        $this->root->emit('\OC\Files', 'preCopy', [$source, $target]);
202
+        $this->legacyDispatcher->dispatch('\OCP\Files::preCopy', new GenericEvent([$source, $target]));
203
+
204
+        $event = new BeforeNodeCopiedEvent($source, $target);
205
+        $this->dispatcher->dispatchTyped($event);
206
+    }
207
+
208
+    public function postCopy($arguments) {
209
+        $source = $this->getNodeForPath($arguments['oldpath']);
210
+        $target = $this->getNodeForPath($arguments['newpath']);
211
+        $this->root->emit('\OC\Files', 'postCopy', [$source, $target]);
212
+        $this->legacyDispatcher->dispatch('\OCP\Files::postCopy', new GenericEvent([$source, $target]));
213
+
214
+        $event = new NodeCopiedEvent($source, $target);
215
+        $this->dispatcher->dispatchTyped($event);
216
+    }
217
+
218
+    public function read($arguments) {
219
+        $node = $this->getNodeForPath($arguments['path']);
220
+        $this->root->emit('\OC\Files', 'read', [$node]);
221
+        $this->legacyDispatcher->dispatch('\OCP\Files::read', new GenericEvent([$node]));
222
+
223
+        $event = new BeforeNodeReadEvent($node);
224
+        $this->dispatcher->dispatchTyped($event);
225
+    }
226
+
227
+    private function getNodeForPath($path) {
228
+        $info = Filesystem::getView()->getFileInfo($path);
229
+        if (!$info) {
230
+            $fullPath = Filesystem::getView()->getAbsolutePath($path);
231
+            if (isset($this->deleteMetaCache[$fullPath])) {
232
+                $info = $this->deleteMetaCache[$fullPath];
233
+            } else {
234
+                $info = null;
235
+            }
236
+            if (Filesystem::is_dir($path)) {
237
+                return new NonExistingFolder($this->root, $this->view, $fullPath, $info);
238
+            } else {
239
+                return new NonExistingFile($this->root, $this->view, $fullPath, $info);
240
+            }
241
+        }
242
+        if ($info->getType() === FileInfo::TYPE_FILE) {
243
+            return new File($this->root, $this->view, $info->getPath(), $info);
244
+        } else {
245
+            return new Folder($this->root, $this->view, $info->getPath(), $info);
246
+        }
247
+    }
248 248
 }
Please login to merge, or discard this patch.