Skip to content

Commit e9c9b86

Browse files
authored
$enforcer->setWatcher($watcher); 放上面
放下面:echo "Now should reload all policies." . PHP_EOL; 不会被执行
1 parent 512d4c8 commit e9c9b86

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,15 @@ $worker->onWorkerStart = function () {
4040
// Initialize the Enforcer.
4141
$enforcer = new Enforcer("path/to/model.conf", "path/to/policy.csv");
4242

43+
$enforcer->setWatcher($watcher);
44+
4345
// Set callback, sets the callback function that the watcher will call,
4446
// When the policy in DB has been changed by other instances.
4547
// A classic callback is $enforcer->loadPolicy().
4648
$watcher->setUpdateCallback(function () use ($enforcer) {
4749
echo "Now should reload all policies." . PHP_EOL;
4850
$enforcer->loadPolicy();
4951
});
50-
51-
$enforcer->setWatcher($watcher);
52-
5352
};
5453

5554
Worker::runAll();

0 commit comments

Comments
 (0)