Completed
Pull Request — master (#558)
by
unknown
20:45
created

FilesHooksStatic::fileBeforeRename()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
crap 2
1
<?php
2
/**
3
 * @author Joas Schilling <[email protected]>
4
 * @author Vincent Petry <[email protected]>
5
 *
6
 * @copyright Copyright (c) 2016, ownCloud, Inc.
7
 * @license AGPL-3.0
8
 *
9
 * This code is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU Affero General Public License, version 3,
11
 * as published by the Free Software Foundation.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
 * GNU Affero General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Affero General Public License, version 3,
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
20
 *
21
 */
22
23
namespace OCA\Activity;
24
25
use OCP\Util;
26
27
/**
28
 * The class to handle the filesystem hooks
29
 */
30
class FilesHooksStatic {
31
32
	/**
33
	 * @var Appinfo\Application
34
	 */
35
	private static $app = null;
36
37
	/**
38
	 * @return FilesHooks
39
	 */
40
	static protected function getHooks() {
41
		if (self::$app === null) {
42
			self::$app = new AppInfo\Application();
43
		}
44
		return self::$app->getContainer()->query('Hooks');
45
	}
46
47
	/**
48
	 * Store the create hook events
49
	 * @param array $params The hook params
50
	 */
51
	public static function fileCreate($params) {
52
		self::getHooks()->fileCreate($params['path']);
53
	}
54
55
	/**
56
	 * Store the update hook events
57
	 * @param array $params The hook params
58
	 */
59
	public static function fileUpdate($params) {
60
		self::getHooks()->fileUpdate($params['path']);
61
	}
62
63
	/**
64
	 * Store the delete hook events
65
	 * @param array $params The hook params
66
	 */
67
	public static function fileDelete($params) {
68
		self::getHooks()->fileDelete($params['path']);
69
	}
70
71
	/**
72
	 * Store the preRename hook events
73
	 * @param array $params The hook params
74
	 */
75
	public static function fileBeforeRename($params) {
76
		self::getHooks()->fileBeforeRename(
77
			$params['oldpath'],
78
			$params['newpath']
79
		);
80
	}
81
82
	/**
83
	 * Store the rename hook events
84
	 * @param array $params The hook params
85
	 */
86
	public static function fileRename($params) {
87
		self::getHooks()->fileRename(
88
			$params['oldpath'],
89
			$params['newpath']
90
		);
91
	}
92
93
	/**
94
	 * Store the restore hook events
95
	 * @param array $params The hook params
96
	 */
97
	public static function fileRestore($params) {
98
		self::getHooks()->fileRestore($params['filePath']);
99
	}
100
101
	/**
102
	 * Manage sharing events
103
	 * @param array $params The hook params
104
	 */
105
	public static function share($params) {
106
		self::getHooks()->share($params);
107
	}
108
109
	/**
110
	 * Manage sharing events
111
	 * @param array $params The hook params
112
	 */
113
	public static function unShare($params) {
114
		self::getHooks()->unShare($params);
115
	}
116
117
	/**
118
	 * Load additional scripts when the files app is visible
119
	 */
120
	public static function onLoadFilesAppScripts() {
121
		Util::addStyle('activity', 'style');
122
		Util::addScript('activity', 'formatter');
123
		Util::addScript('activity', 'activitymodel');
124
		Util::addScript('activity', 'activitycollection');
125
		Util::addScript('activity', 'activitytabview');
126
		Util::addScript('activity', 'filesplugin');
127
	}
128
}
129