Skip to content

Commit 04cbfed

Browse files
committed
added update / remove plugin triggers
1 parent f03319d commit 04cbfed

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/Plugin.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ public function __construct(Mapper $mapper)
1414
public function getRepositoryClass(Space $space) {}
1515
public function getEntityClass(Space $space) {}
1616
public function beforeCreate(Entity $instance, Space $space) {}
17-
}
17+
public function beforeUpdate(Entity $instance, Space $space) {}
18+
public function beforeRemove(Entity $instance, Space $space) {}
19+
}

src/Repository.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ public function remove($instance)
195195
foreach($this->space->getPrimaryIndex()->parts as $part) {
196196
$pk[] = $this->original[$key][$part[0]];
197197
}
198+
$plugin->beforeRemove($instance, $this->space);
198199

199200
$this->space->getMapper()->getClient()
200201
->getSpace($this->space->getId())
@@ -248,6 +249,7 @@ public function save($instance)
248249
foreach($this->space->getPrimaryIndex()->parts as $part) {
249250
$pk[] = $this->original[$key][$part[0]];
250251
}
252+
$plugin->beforeCreate($instance, $this->space);
251253

252254
$client->getSpace($this->space->getId())->update($pk, $operations);
253255
$this->original[$key] = $tuple;
@@ -266,4 +268,4 @@ public function flushCache()
266268
{
267269
$this->cache = [];
268270
}
269-
}
271+
}

0 commit comments

Comments
 (0)