diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2020-10-19 09:49:04 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2020-10-20 14:39:28 +0200 |
commit | 3e1916080af3ec2bc2fb7fd64f127cbd0c9b8a76 (patch) | |
tree | 7bb108093985d85174604db408992d58195501f6 /lib/private/Comments | |
parent | afa737652247365838832837ae4ce20bca039ad9 (diff) | |
download | nextcloud-server-3e1916080af3ec2bc2fb7fd64f127cbd0c9b8a76.tar.gz nextcloud-server-3e1916080af3ec2bc2fb7fd64f127cbd0c9b8a76.zip |
Add ICommentsManager::load method
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'lib/private/Comments')
-rw-r--r-- | lib/private/Comments/Manager.php | 26 | ||||
-rw-r--r-- | lib/private/Comments/ManagerFactory.php | 4 |
2 files changed, 24 insertions, 6 deletions
diff --git a/lib/private/Comments/Manager.php b/lib/private/Comments/Manager.php index 39d1f2c847f..3c9be9828d1 100644 --- a/lib/private/Comments/Manager.php +++ b/lib/private/Comments/Manager.php @@ -30,6 +30,7 @@ namespace OC\Comments; use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Exception\InvalidFieldNameException; +use OCA\Comments\AppInfo\Application; use OCP\Comments\CommentsEvent; use OCP\Comments\IComment; use OCP\Comments\ICommentsEventHandler; @@ -39,6 +40,8 @@ use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IConfig; use OCP\IDBConnection; use OCP\IUser; +use OCP\IInitialStateService; +use OCP\Util; use Psr\Log\LoggerInterface; class Manager implements ICommentsManager { @@ -52,6 +55,9 @@ class Manager implements ICommentsManager { /** @var IConfig */ protected $config; + /** @var IInitialStateService */ + protected $initialStateService; + /** @var IComment[] */ protected $commentsCache = []; @@ -64,14 +70,14 @@ class Manager implements ICommentsManager { /** @var \Closure[] */ protected $displayNameResolvers = []; - public function __construct( - IDBConnection $dbConn, - LoggerInterface $logger, - IConfig $config - ) { + public function __construct(IDBConnection $dbConn, + LoggerInterface $logger, + IConfig $config, + IInitialStateService $initialStateService) { $this->dbConn = $dbConn; $this->logger = $logger; $this->config = $config; + $this->initialStateService = $initialStateService; } /** @@ -1120,4 +1126,14 @@ class Manager implements ICommentsManager { $entity->handle($event); } } + + /** + * Load the Comments app into the page + * + * @since 21.0.0 + */ + public function load(): void { + $this->initialStateService->provideInitialState(Application::APP_ID, 'max-message-length', IComment::MAX_MESSAGE_LENGTH); + Util::addScript(Application::APP_ID, 'comments-app'); + } } diff --git a/lib/private/Comments/ManagerFactory.php b/lib/private/Comments/ManagerFactory.php index 4888b133143..44edf32cf9c 100644 --- a/lib/private/Comments/ManagerFactory.php +++ b/lib/private/Comments/ManagerFactory.php @@ -27,6 +27,7 @@ namespace OC\Comments; use OCP\Comments\ICommentsManager; use OCP\Comments\ICommentsManagerFactory; +use OCP\IInitialStateService; use OCP\IServerContainer; use Psr\Log\LoggerInterface; @@ -58,7 +59,8 @@ class ManagerFactory implements ICommentsManagerFactory { return new Manager( $this->serverContainer->getDatabaseConnection(), $this->serverContainer->get(LoggerInterface::class), - $this->serverContainer->getConfig() + $this->serverContainer->getConfig(), + $this->serverContainer->get(IInitialStateService::class) ); } } |