@@ -29,12 +29,12 @@ |
||
29 | 29 | * Wrap a command in the background job interface |
30 | 30 | */ |
31 | 31 | class CommandJob extends QueuedJob { |
32 | - protected function run($serializedCommand) { |
|
33 | - $command = unserialize($serializedCommand); |
|
34 | - if ($command instanceof ICommand) { |
|
35 | - $command->handle(); |
|
36 | - } else { |
|
37 | - throw new \InvalidArgumentException('Invalid serialized command'); |
|
38 | - } |
|
39 | - } |
|
32 | + protected function run($serializedCommand) { |
|
33 | + $command = unserialize($serializedCommand); |
|
34 | + if ($command instanceof ICommand) { |
|
35 | + $command->handle(); |
|
36 | + } else { |
|
37 | + throw new \InvalidArgumentException('Invalid serialized command'); |
|
38 | + } |
|
39 | + } |
|
40 | 40 | } |
@@ -24,23 +24,23 @@ |
||
24 | 24 | namespace OC\Template; |
25 | 25 | |
26 | 26 | class ResourceNotFoundException extends \LogicException { |
27 | - protected $resource; |
|
28 | - protected $webPath; |
|
27 | + protected $resource; |
|
28 | + protected $webPath; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @param string $resource |
|
32 | - * @param string $webPath |
|
33 | - */ |
|
34 | - public function __construct($resource, $webPath) { |
|
35 | - parent::__construct('Resource not found'); |
|
36 | - $this->resource = $resource; |
|
37 | - $this->webPath = $webPath; |
|
38 | - } |
|
30 | + /** |
|
31 | + * @param string $resource |
|
32 | + * @param string $webPath |
|
33 | + */ |
|
34 | + public function __construct($resource, $webPath) { |
|
35 | + parent::__construct('Resource not found'); |
|
36 | + $this->resource = $resource; |
|
37 | + $this->webPath = $webPath; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @return string |
|
42 | - */ |
|
43 | - public function getResourcePath() { |
|
44 | - return $this->webPath . '/' . $this->resource; |
|
45 | - } |
|
40 | + /** |
|
41 | + * @return string |
|
42 | + */ |
|
43 | + public function getResourcePath() { |
|
44 | + return $this->webPath . '/' . $this->resource; |
|
45 | + } |
|
46 | 46 | } |
@@ -26,37 +26,37 @@ |
||
26 | 26 | namespace OC\Template; |
27 | 27 | |
28 | 28 | class TemplateFileLocator { |
29 | - protected $dirs; |
|
30 | - private $path; |
|
29 | + protected $dirs; |
|
30 | + private $path; |
|
31 | 31 | |
32 | - /** |
|
33 | - * @param string[] $dirs |
|
34 | - */ |
|
35 | - public function __construct( $dirs ) { |
|
36 | - $this->dirs = $dirs; |
|
37 | - } |
|
32 | + /** |
|
33 | + * @param string[] $dirs |
|
34 | + */ |
|
35 | + public function __construct( $dirs ) { |
|
36 | + $this->dirs = $dirs; |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param string $template |
|
41 | - * @return string |
|
42 | - * @throws \Exception |
|
43 | - */ |
|
44 | - public function find( $template ) { |
|
45 | - if ($template === '') { |
|
46 | - throw new \InvalidArgumentException('Empty template name'); |
|
47 | - } |
|
39 | + /** |
|
40 | + * @param string $template |
|
41 | + * @return string |
|
42 | + * @throws \Exception |
|
43 | + */ |
|
44 | + public function find( $template ) { |
|
45 | + if ($template === '') { |
|
46 | + throw new \InvalidArgumentException('Empty template name'); |
|
47 | + } |
|
48 | 48 | |
49 | - foreach($this->dirs as $dir) { |
|
50 | - $file = $dir.$template.'.php'; |
|
51 | - if (is_file($file)) { |
|
52 | - $this->path = $dir; |
|
53 | - return $file; |
|
54 | - } |
|
55 | - } |
|
56 | - throw new \Exception('template file not found: template:'.$template); |
|
57 | - } |
|
49 | + foreach($this->dirs as $dir) { |
|
50 | + $file = $dir.$template.'.php'; |
|
51 | + if (is_file($file)) { |
|
52 | + $this->path = $dir; |
|
53 | + return $file; |
|
54 | + } |
|
55 | + } |
|
56 | + throw new \Exception('template file not found: template:'.$template); |
|
57 | + } |
|
58 | 58 | |
59 | - public function getPath() { |
|
60 | - return $this->path; |
|
61 | - } |
|
59 | + public function getPath() { |
|
60 | + return $this->path; |
|
61 | + } |
|
62 | 62 | } |
@@ -24,5 +24,5 @@ |
||
24 | 24 | namespace OC\Hooks; |
25 | 25 | |
26 | 26 | abstract class BasicEmitter implements Emitter { |
27 | - use EmitterTrait; |
|
27 | + use EmitterTrait; |
|
28 | 28 | } |
@@ -32,19 +32,19 @@ |
||
32 | 32 | * @package OC\Hooks |
33 | 33 | */ |
34 | 34 | interface Emitter { |
35 | - /** |
|
36 | - * @param string $scope |
|
37 | - * @param string $method |
|
38 | - * @param callable $callback |
|
39 | - * @return void |
|
40 | - */ |
|
41 | - public function listen($scope, $method, callable $callback); |
|
35 | + /** |
|
36 | + * @param string $scope |
|
37 | + * @param string $method |
|
38 | + * @param callable $callback |
|
39 | + * @return void |
|
40 | + */ |
|
41 | + public function listen($scope, $method, callable $callback); |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param string $scope optional |
|
45 | - * @param string $method optional |
|
46 | - * @param callable $callback optional |
|
47 | - * @return void |
|
48 | - */ |
|
49 | - public function removeListener($scope = null, $method = null, callable $callback = null); |
|
43 | + /** |
|
44 | + * @param string $scope optional |
|
45 | + * @param string $method optional |
|
46 | + * @param callable $callback optional |
|
47 | + * @return void |
|
48 | + */ |
|
49 | + public function removeListener($scope = null, $method = null, callable $callback = null); |
|
50 | 50 | } |
@@ -24,12 +24,12 @@ |
||
24 | 24 | namespace OC\Hooks; |
25 | 25 | |
26 | 26 | class PublicEmitter extends BasicEmitter { |
27 | - /** |
|
28 | - * @param string $scope |
|
29 | - * @param string $method |
|
30 | - * @param array $arguments optional |
|
31 | - */ |
|
32 | - public function emit($scope, $method, array $arguments = array()) { |
|
33 | - parent::emit($scope, $method, $arguments); |
|
34 | - } |
|
27 | + /** |
|
28 | + * @param string $scope |
|
29 | + * @param string $method |
|
30 | + * @param array $arguments optional |
|
31 | + */ |
|
32 | + public function emit($scope, $method, array $arguments = array()) { |
|
33 | + parent::emit($scope, $method, $arguments); |
|
34 | + } |
|
35 | 35 | } |
@@ -31,35 +31,35 @@ |
||
31 | 31 | * @package OC\Hooks |
32 | 32 | */ |
33 | 33 | abstract class ForwardingEmitter extends BasicEmitter { |
34 | - /** |
|
35 | - * @var \OC\Hooks\Emitter[] array |
|
36 | - */ |
|
37 | - private $forwardEmitters = array(); |
|
34 | + /** |
|
35 | + * @var \OC\Hooks\Emitter[] array |
|
36 | + */ |
|
37 | + private $forwardEmitters = array(); |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param string $scope |
|
41 | - * @param string $method |
|
42 | - * @param callable $callback |
|
43 | - */ |
|
44 | - public function listen($scope, $method, callable $callback) { |
|
45 | - parent::listen($scope, $method, $callback); |
|
46 | - foreach ($this->forwardEmitters as $emitter) { |
|
47 | - $emitter->listen($scope, $method, $callback); |
|
48 | - } |
|
49 | - } |
|
39 | + /** |
|
40 | + * @param string $scope |
|
41 | + * @param string $method |
|
42 | + * @param callable $callback |
|
43 | + */ |
|
44 | + public function listen($scope, $method, callable $callback) { |
|
45 | + parent::listen($scope, $method, $callback); |
|
46 | + foreach ($this->forwardEmitters as $emitter) { |
|
47 | + $emitter->listen($scope, $method, $callback); |
|
48 | + } |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * @param \OC\Hooks\Emitter $emitter |
|
53 | - */ |
|
54 | - protected function forward(Emitter $emitter) { |
|
55 | - $this->forwardEmitters[] = $emitter; |
|
51 | + /** |
|
52 | + * @param \OC\Hooks\Emitter $emitter |
|
53 | + */ |
|
54 | + protected function forward(Emitter $emitter) { |
|
55 | + $this->forwardEmitters[] = $emitter; |
|
56 | 56 | |
57 | - //forward all previously connected hooks |
|
58 | - foreach ($this->listeners as $key => $listeners) { |
|
59 | - list($scope, $method) = explode('::', $key, 2); |
|
60 | - foreach ($listeners as $listener) { |
|
61 | - $emitter->listen($scope, $method, $listener); |
|
62 | - } |
|
63 | - } |
|
64 | - } |
|
57 | + //forward all previously connected hooks |
|
58 | + foreach ($this->listeners as $key => $listeners) { |
|
59 | + list($scope, $method) = explode('::', $key, 2); |
|
60 | + foreach ($listeners as $listener) { |
|
61 | + $emitter->listen($scope, $method, $listener); |
|
62 | + } |
|
63 | + } |
|
64 | + } |
|
65 | 65 | } |
@@ -24,8 +24,8 @@ |
||
24 | 24 | namespace OC\Hooks; |
25 | 25 | |
26 | 26 | abstract class LegacyEmitter extends BasicEmitter { |
27 | - protected function emit($scope, $method, array $arguments = array()) { |
|
28 | - \OC_Hook::emit($scope, $method, $arguments); |
|
29 | - parent::emit($scope, $method, $arguments); |
|
30 | - } |
|
27 | + protected function emit($scope, $method, array $arguments = array()) { |
|
28 | + \OC_Hook::emit($scope, $method, $arguments); |
|
29 | + parent::emit($scope, $method, $arguments); |
|
30 | + } |
|
31 | 31 | } |
@@ -24,80 +24,80 @@ |
||
24 | 24 | |
25 | 25 | trait EmitterTrait { |
26 | 26 | |
27 | - /** |
|
28 | - * @var (callable[])[] $listeners |
|
29 | - */ |
|
30 | - protected $listeners = array(); |
|
27 | + /** |
|
28 | + * @var (callable[])[] $listeners |
|
29 | + */ |
|
30 | + protected $listeners = array(); |
|
31 | 31 | |
32 | - /** |
|
33 | - * @param string $scope |
|
34 | - * @param string $method |
|
35 | - * @param callable $callback |
|
36 | - */ |
|
37 | - public function listen($scope, $method, callable $callback) { |
|
38 | - $eventName = $scope . '::' . $method; |
|
39 | - if (!isset($this->listeners[$eventName])) { |
|
40 | - $this->listeners[$eventName] = array(); |
|
41 | - } |
|
42 | - if (array_search($callback, $this->listeners[$eventName], true) === false) { |
|
43 | - $this->listeners[$eventName][] = $callback; |
|
44 | - } |
|
45 | - } |
|
32 | + /** |
|
33 | + * @param string $scope |
|
34 | + * @param string $method |
|
35 | + * @param callable $callback |
|
36 | + */ |
|
37 | + public function listen($scope, $method, callable $callback) { |
|
38 | + $eventName = $scope . '::' . $method; |
|
39 | + if (!isset($this->listeners[$eventName])) { |
|
40 | + $this->listeners[$eventName] = array(); |
|
41 | + } |
|
42 | + if (array_search($callback, $this->listeners[$eventName], true) === false) { |
|
43 | + $this->listeners[$eventName][] = $callback; |
|
44 | + } |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * @param string $scope optional |
|
49 | - * @param string $method optional |
|
50 | - * @param callable $callback optional |
|
51 | - */ |
|
52 | - public function removeListener($scope = null, $method = null, callable $callback = null) { |
|
53 | - $names = array(); |
|
54 | - $allNames = array_keys($this->listeners); |
|
55 | - if ($scope and $method) { |
|
56 | - $name = $scope . '::' . $method; |
|
57 | - if (isset($this->listeners[$name])) { |
|
58 | - $names[] = $name; |
|
59 | - } |
|
60 | - } elseif ($scope) { |
|
61 | - foreach ($allNames as $name) { |
|
62 | - $parts = explode('::', $name, 2); |
|
63 | - if ($parts[0] == $scope) { |
|
64 | - $names[] = $name; |
|
65 | - } |
|
66 | - } |
|
67 | - } elseif ($method) { |
|
68 | - foreach ($allNames as $name) { |
|
69 | - $parts = explode('::', $name, 2); |
|
70 | - if ($parts[1] == $method) { |
|
71 | - $names[] = $name; |
|
72 | - } |
|
73 | - } |
|
74 | - } else { |
|
75 | - $names = $allNames; |
|
76 | - } |
|
47 | + /** |
|
48 | + * @param string $scope optional |
|
49 | + * @param string $method optional |
|
50 | + * @param callable $callback optional |
|
51 | + */ |
|
52 | + public function removeListener($scope = null, $method = null, callable $callback = null) { |
|
53 | + $names = array(); |
|
54 | + $allNames = array_keys($this->listeners); |
|
55 | + if ($scope and $method) { |
|
56 | + $name = $scope . '::' . $method; |
|
57 | + if (isset($this->listeners[$name])) { |
|
58 | + $names[] = $name; |
|
59 | + } |
|
60 | + } elseif ($scope) { |
|
61 | + foreach ($allNames as $name) { |
|
62 | + $parts = explode('::', $name, 2); |
|
63 | + if ($parts[0] == $scope) { |
|
64 | + $names[] = $name; |
|
65 | + } |
|
66 | + } |
|
67 | + } elseif ($method) { |
|
68 | + foreach ($allNames as $name) { |
|
69 | + $parts = explode('::', $name, 2); |
|
70 | + if ($parts[1] == $method) { |
|
71 | + $names[] = $name; |
|
72 | + } |
|
73 | + } |
|
74 | + } else { |
|
75 | + $names = $allNames; |
|
76 | + } |
|
77 | 77 | |
78 | - foreach ($names as $name) { |
|
79 | - if ($callback) { |
|
80 | - $index = array_search($callback, $this->listeners[$name], true); |
|
81 | - if ($index !== false) { |
|
82 | - unset($this->listeners[$name][$index]); |
|
83 | - } |
|
84 | - } else { |
|
85 | - $this->listeners[$name] = array(); |
|
86 | - } |
|
87 | - } |
|
88 | - } |
|
78 | + foreach ($names as $name) { |
|
79 | + if ($callback) { |
|
80 | + $index = array_search($callback, $this->listeners[$name], true); |
|
81 | + if ($index !== false) { |
|
82 | + unset($this->listeners[$name][$index]); |
|
83 | + } |
|
84 | + } else { |
|
85 | + $this->listeners[$name] = array(); |
|
86 | + } |
|
87 | + } |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * @param string $scope |
|
92 | - * @param string $method |
|
93 | - * @param array $arguments optional |
|
94 | - */ |
|
95 | - protected function emit($scope, $method, array $arguments = array()) { |
|
96 | - $eventName = $scope . '::' . $method; |
|
97 | - if (isset($this->listeners[$eventName])) { |
|
98 | - foreach ($this->listeners[$eventName] as $callback) { |
|
99 | - call_user_func_array($callback, $arguments); |
|
100 | - } |
|
101 | - } |
|
102 | - } |
|
90 | + /** |
|
91 | + * @param string $scope |
|
92 | + * @param string $method |
|
93 | + * @param array $arguments optional |
|
94 | + */ |
|
95 | + protected function emit($scope, $method, array $arguments = array()) { |
|
96 | + $eventName = $scope . '::' . $method; |
|
97 | + if (isset($this->listeners[$eventName])) { |
|
98 | + foreach ($this->listeners[$eventName] as $callback) { |
|
99 | + call_user_func_array($callback, $arguments); |
|
100 | + } |
|
101 | + } |
|
102 | + } |
|
103 | 103 | } |