Add backend support for comments
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -23,12 +23,15 @@
|
||||
|
||||
namespace OCA\Deck\AppInfo;
|
||||
|
||||
use OCA\Deck\Activity\CommentEventHandler;
|
||||
use OCA\Deck\Db\Acl;
|
||||
use OCA\Deck\Db\AclMapper;
|
||||
use OCA\Deck\Db\AssignedUsersMapper;
|
||||
use OCA\Deck\Db\CardMapper;
|
||||
use OCA\Deck\Notification\Notifier;
|
||||
use OCP\AppFramework\App;
|
||||
use OCA\Deck\Middleware\SharingMiddleware;
|
||||
use OCP\Comments\CommentsEntityEvent;
|
||||
use OCP\IGroup;
|
||||
use OCP\IUser;
|
||||
use OCP\IUserManager;
|
||||
@@ -120,6 +123,27 @@ class Application extends App {
|
||||
}, function() {
|
||||
return ['id' => 'deck', 'name' => 'Deck'];
|
||||
});
|
||||
}
|
||||
|
||||
public function registerCommentsEntity() {
|
||||
$this->getContainer()->getServer()->getEventDispatcher()->addListener(CommentsEntityEvent::EVENT_ENTITY, function(CommentsEntityEvent $event) {
|
||||
$event->addEntityCollection('deckCard', function($name) {
|
||||
/** @var CardMapper */
|
||||
$service = $this->getContainer()->query(CardMapper::class);
|
||||
try {
|
||||
$card = $service->find((int) $name);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
});
|
||||
$this->registerCommentsEventHandler();
|
||||
}
|
||||
|
||||
protected function registerCommentsEventHandler() {
|
||||
$this->getContainer()->getServer()->getCommentsManager()->registerEventHandler(function () {
|
||||
return $this->getContainer()->query(CommentEventHandler::class);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user