summaryrefslogtreecommitdiffstats
path: root/lib/private/Files/Node/Node.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Files/Node/Node.php')
-rw-r--r--lib/private/Files/Node/Node.php24
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/private/Files/Node/Node.php b/lib/private/Files/Node/Node.php
index dc025b79575..c440dd4a8f1 100644
--- a/lib/private/Files/Node/Node.php
+++ b/lib/private/Files/Node/Node.php
@@ -33,6 +33,7 @@ use OCP\Files\FileInfo;
use OCP\Files\InvalidPathException;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
+use Symfony\Component\EventDispatcher\GenericEvent;
// FIXME: this class really should be abstract
class Node implements \OCP\Files\Node {
@@ -104,9 +105,12 @@ class Node implements \OCP\Files\Node {
/**
* @param string[] $hooks
*/
- protected function sendHooks($hooks) {
+ protected function sendHooks($hooks, array $args = null) {
+ $args = !empty($args) ? $args : [$this];
+ $dispatcher = \OC::$server->getEventDispatcher();
foreach ($hooks as $hook) {
- $this->root->emit('\OC\Files', $hook, array($this));
+ $this->root->emit('\OC\Files', $hook, $args);
+ $dispatcher->dispatch('\OCP\Files::' . $hook, new GenericEvent($args));
}
}
@@ -394,14 +398,14 @@ class Node implements \OCP\Files\Node {
$parent = $this->root->get(dirname($targetPath));
if ($parent instanceof Folder and $this->isValidPath($targetPath) and $parent->isCreatable()) {
$nonExisting = $this->createNonExistingNode($targetPath);
- $this->root->emit('\OC\Files', 'preCopy', [$this, $nonExisting]);
- $this->root->emit('\OC\Files', 'preWrite', [$nonExisting]);
+ $this->sendHooks(['preCopy'], [$this, $nonExisting]);
+ $this->sendHooks(['preWrite'], [$nonExisting]);
if (!$this->view->copy($this->path, $targetPath)) {
throw new NotPermittedException('Could not copy ' . $this->path . ' to ' . $targetPath);
}
$targetNode = $this->root->get($targetPath);
- $this->root->emit('\OC\Files', 'postCopy', [$this, $targetNode]);
- $this->root->emit('\OC\Files', 'postWrite', [$targetNode]);
+ $this->sendHooks(['postCopy'], [$this, $targetNode]);
+ $this->sendHooks(['postWrite'], [$targetNode]);
return $targetNode;
} else {
throw new NotPermittedException('No permission to copy to path ' . $targetPath);
@@ -425,14 +429,14 @@ class Node implements \OCP\Files\Node {
)
) {
$nonExisting = $this->createNonExistingNode($targetPath);
- $this->root->emit('\OC\Files', 'preRename', [$this, $nonExisting]);
- $this->root->emit('\OC\Files', 'preWrite', [$nonExisting]);
+ $this->sendHooks(['preRename'], [$this, $nonExisting]);
+ $this->sendHooks(['preWrite'], [$nonExisting]);
if (!$this->view->rename($this->path, $targetPath)) {
throw new NotPermittedException('Could not move ' . $this->path . ' to ' . $targetPath);
}
$targetNode = $this->root->get($targetPath);
- $this->root->emit('\OC\Files', 'postRename', [$this, $targetNode]);
- $this->root->emit('\OC\Files', 'postWrite', [$targetNode]);
+ $this->sendHooks(['postRename'], [$this, $targetNode]);
+ $this->sendHooks(['postWrite'], [$targetNode]);
$this->path = $targetPath;
return $targetNode;
} else {