Manager

class OC\Comments\Manager
Source:lib/private/Comments/Manager.php#48
Implements:OCP\Comments\ICommentsManager

Properties

protected static property OC\Comments\Manager::$dbConn
Source:lib/private/Comments/Manager.php#51
Type:\OCP\IDBConnection
protected static property OC\Comments\Manager::$logger
Source:lib/private/Comments/Manager.php#54
Type:\Psr\Log\LoggerInterface
protected static property OC\Comments\Manager::$config
Source:lib/private/Comments/Manager.php#57
Type:\OCP\IConfig
protected static property OC\Comments\Manager::$timeFactory
Source:lib/private/Comments/Manager.php#60
Type:\OCP\AppFramework\Utility\ITimeFactory
protected static property OC\Comments\Manager::$initialStateService
Source:lib/private/Comments/Manager.php#63
Type:\OCP\IInitialStateService
protected static property OC\Comments\Manager::$commentsCache
Source:lib/private/Comments/Manager.php#66
Type:\OCP\Comments\IComment[]
protected static property OC\Comments\Manager::$eventHandlerClosures
Source:lib/private/Comments/Manager.php#69
Type:\Closure[]
protected static property OC\Comments\Manager::$eventHandlers
Source:lib/private/Comments/Manager.php#72
Type:\OCP\Comments\ICommentsEventHandler[]
protected static property OC\Comments\Manager::$displayNameResolvers
Source:lib/private/Comments/Manager.php#75
Type:\Closure[]

Methods

public OC\Comments\Manager::__construct($dbConn, $logger, $config, $timeFactory, $initialStateService)
Source:lib/private/Comments/Manager.php#77
protected OC\Comments\Manager::normalizeDatabaseData($data)
converts data base data into PHP native, proper types as defined by
IComment interface.
Source:

lib/private/Comments/Manager.php#96

Parameters:
  • $data (array)
Returns:

array

public OC\Comments\Manager::getCommentFromData($data)
Source:

lib/private/Comments/Manager.php#114

Parameters:
  • $data (array)
Returns:

\OCP\Comments\IComment

protected OC\Comments\Manager::prepareCommentForDatabaseWrite($comment)
prepares a comment for an insert or update operation after making sure
all necessary fields have a value assigned.
Source:

lib/private/Comments/Manager.php#127

Parameters:
Returns:

\OCP\Comments\IComment returns the same updated IComment instance as provided by parameter for convenience

Throws:

\UnexpectedValueException

protected OC\Comments\Manager::determineTopmostParentId($id)
returns the topmost parent id of a given comment identified by ID
Source:

lib/private/Comments/Manager.php#165

Parameters:
  • $id (string)
Returns:

string

Throws:

\OCP\Comments\NotFoundException

protected OC\Comments\Manager::updateChildrenInformation($id, $cDateTime)
updates child information of a comment
Source:

lib/private/Comments/Manager.php#181

Parameters:
  • $id (string)
  • $cDateTime (DateTime) the date time of the most recent child
Throws:

\OCP\Comments\NotFoundException

protected OC\Comments\Manager::checkRoleParameters($role, $type, $id)
Tests whether actor or object type and id parameters are acceptable.
Throws exception if not.
Source:

lib/private/Comments/Manager.php#208

Parameters:
  • $role (string)
  • $type (string)
  • $id (string)
Throws:

\InvalidArgumentException

protected OC\Comments\Manager::cache($comment)
run-time caches a comment
Source:

lib/private/Comments/Manager.php#222

Parameters:
protected OC\Comments\Manager::uncache($id)
removes an entry from the comments run time cache
Source:

lib/private/Comments/Manager.php#235

Parameters:
  • $id (mixed) the comment’s id
public OC\Comments\Manager::get($id)
returns a comment instance
Source:

lib/private/Comments/Manager.php#251

Parameters:
  • $id (string) the ID of the comment
Returns:

\OCP\Comments\IComment

Throws:

\OCP\Comments\NotFoundException

Throws:

\InvalidArgumentException

Throws:

\OCP\Comments\NotFoundException

Throws:

\InvalidArgumentException

Since:

9.0.0

public OC\Comments\Manager::getTree($id, $limit=0, $offset=0)
returns the comment specified by the id and all it’s child comments.
At this point of time, we do only support one level depth.
Source:

lib/private/Comments/Manager.php#308

Parameters:
  • $id (string)
  • $limit (int) max number of entries to return, 0 returns all
  • $offset (int) the start entry
Returns:

array

Since:

9.0.0 The return array looks like this [

‘comment’ => IComment, // root comment ‘replies’ => [

0 => [

‘comment’ => IComment, ‘replies’ => []

] 1 => [

‘comment’ => IComment, ‘replies’=> []

], …

]

]

public OC\Comments\Manager::getForObject($objectType, $objectId, $limit=0, $offset=0, $notOlderThan=null)
returns comments for a specific object (e.g. a file).
The sort order is always newest to oldest.
Source:

lib/private/Comments/Manager.php#356

Parameters:
  • $objectType (string) the object type, e.g. ‘files’
  • $objectId (string) the id of the object
  • $limit (int) optional, number of maximum comments to be returned. if

not specified, all comments are returned. * $offset (int) optional, starting point * $notOlderThan (DateTime) optional, timestamp of the oldest comments that may be returned

Returns:

\OCP\Comments\IComment[]

Since:

9.0.0

public OC\Comments\Manager::getForObjectSince($objectType, $objectId, $lastKnownCommentId, $sortDirection=asc, $limit=30, $includeLastKnown=false)
Source:

lib/private/Comments/Manager.php#408

Parameters:
  • $objectType (string) the object type, e.g. ‘files’
  • $objectId (string) the id of the object
  • $lastKnownCommentId (int) the last known comment (will be used as offset)
  • $sortDirection (string) direction of the comments (asc or desc)
  • $limit (int) optional, number of maximum comments to be returned. if

set to 0, all comments are returned. * $includeLastKnown (bool)

Returns:

\OCP\Comments\IComment[]

Returns:

\OCP\Comments\IComment[]

protected OC\Comments\Manager::getLastKnownComment($objectType, $objectId, $id)
Source:

lib/private/Comments/Manager.php#503

Parameters:
  • $objectType (string) the object type, e.g. ‘files’
  • $objectId (string) the id of the object
  • $id (int) the comment to look for
Returns:

\OC\Comments\Comment | null

public OC\Comments\Manager::search($search, $objectType, $objectId, $verb, $offset, $limit=50)
Search for comments with a given content
Source:

lib/private/Comments/Manager.php#537

Parameters:
  • $search (string) content to search for
  • $objectType (string) Limit the search by object type
  • $objectId (string) Limit the search by object id
  • $verb (string) Limit the verb of the comment
  • $offset (int)
  • $limit (int)
Returns:

\OCP\Comments\IComment[]

public OC\Comments\Manager::searchForObjects($search, $objectType, $objectIds, $verb, $offset, $limit=50)
Search for comments on one or more objects with a given content
Source:

lib/private/Comments/Manager.php#556

Parameters:
  • $search (string) content to search for
  • $objectType (string) Limit the search by object type
  • $objectIds (array) Limit the search by object ids
  • $verb (string) Limit the verb of the comment
  • $offset (int)
  • $limit (int)
Returns:

\OCP\Comments\IComment[]

public OC\Comments\Manager::getNumberOfCommentsForObject($objectType, $objectId, $notOlderThan=null, $verb="")
Source:

lib/private/Comments/Manager.php#602

Parameters:
  • $objectType string the object type, e.g. ‘files’
  • $objectId string the id of the object
  • $notOlderThan (DateTime) optional, timestamp of the oldest comments

that may be returned * $verb (string) Limit the verb of the comment - Added in 14.0.0

Returns:

int

Since:

9.0.0

public OC\Comments\Manager::getNumberOfUnreadCommentsForObjects($objectType, $objectIds, $user, $verb="")
Source:

lib/private/Comments/Manager.php#636

Parameters:
  • $objectType (string) the object type, e.g. ‘files’
  • $objectIds (string[]) the id of the object
  • $user (OCP\IUser)
  • $verb (string) Limit the verb of the comment - Added in 14.0.0
Returns:

array Map with object id => # of unread comments

Since:

21.0.0

public OC\Comments\Manager::getNumberOfCommentsForObjectSinceComment($objectType, $objectId, $lastRead, $verb="")
Source:

lib/private/Comments/Manager.php#675

Parameters:
  • $objectType (string)
  • $objectId (string)
  • $lastRead (int)
  • $verb (string)
Returns:

int

Since:

21.0.0

public OC\Comments\Manager::getLastCommentBeforeDate($objectType, $objectId, $beforeDate, $verb="")
Source:

lib/private/Comments/Manager.php#702

Parameters:
  • $objectType (string)
  • $objectId (string)
  • $beforeDate (DateTime)
  • $verb (string)
Returns:

int

Since:

21.0.0

public OC\Comments\Manager::getLastCommentDateByActor($objectType, $objectId, $verb, $actorType, $actors)
Source:

lib/private/Comments/Manager.php#732

Parameters:
  • $objectType (string)
  • $objectId (string)
  • $verb (string)
  • $actorType (string)
  • $actors (string[])
Returns:

\DateTime[] Map of “string actor” => “\DateTime most recent comment date”

Since:

21.0.0

public OC\Comments\Manager::getNumberOfUnreadCommentsForFolder($folderId, $user)
Get the number of unread comments for all files in a folder
Source:

lib/private/Comments/Manager.php#768

Parameters:
Returns:

array [$fileId => $unreadCount]

public OC\Comments\Manager::create($actorType, $actorId, $objectType, $objectId)
creates a new comment and returns it. At this point of time, it is not
saved in the used data storage. Use save() after setting other fields
of the comment (e.g. message or verb).
Source:

lib/private/Comments/Manager.php#826

Parameters:
  • $actorType (string) the actor type (e.g. ‘users’)
  • $actorId (string) a user id
  • $objectType (string) the object type the comment is attached to
  • $objectId (string) the object id the comment is attached to
Returns:

\OCP\Comments\IComment

Since:

9.0.0

public OC\Comments\Manager::delete($id)
permanently deletes the comment specified by the ID
When the comment has child comments, their parent ID will be changed to
the parent ID of the item that is to be deleted.
Source:

lib/private/Comments/Manager.php#845

Parameters:
  • $id (string)
Returns:

bool

Throws:

\InvalidArgumentException

Since:

9.0.0

public OC\Comments\Manager::save($comment)
saves the comment permanently
if the supplied comment has an empty ID, a new entry comment will be
saved and the instance updated with the new ID.

Otherwise, an existing comment will be updated.

Throws NotFoundException when a comment that is to be updated does not
exist anymore at this point of time.
Source:

lib/private/Comments/Manager.php#896

Parameters:
Returns:

bool

Throws:

\OCP\Comments\NotFoundException

Since:

9.0.0

protected OC\Comments\Manager::insert($comment)
inserts the provided comment in the database
Source:

lib/private/Comments/Manager.php#920

Parameters:
Returns:

bool

protected OC\Comments\Manager::insertQuery($comment, $tryWritingReferenceId)
Source:lib/private/Comments/Manager.php#936
protected OC\Comments\Manager::update($comment)
updates a Comment data row
Source:

lib/private/Comments/Manager.php#976

Parameters:
Returns:

bool

Throws:

\OCP\Comments\NotFoundException

protected OC\Comments\Manager::updateQuery($comment, $tryWritingReferenceId)
Source:lib/private/Comments/Manager.php#995
public OC\Comments\Manager::deleteReferencesOfActor($actorType, $actorId)
removes references to specific actor (e.g. on user delete) of a comment.
The comment itself must not get lost/deleted.
Source:

lib/private/Comments/Manager.php#1034

Parameters:
  • $actorType (string) the actor type (e.g. ‘users’)
  • $actorId (string) a user id
Returns:

bool

Since:

9.0.0

public OC\Comments\Manager::deleteCommentsAtObject($objectType, $objectId)
deletes all comments made of a specific object (e.g. on file delete)
Source:

lib/private/Comments/Manager.php#1061

Parameters:
  • $objectType (string) the object type (e.g. ‘files’)
  • $objectId (string) e.g. the file id
Returns:

bool

Since:

9.0.0

public OC\Comments\Manager::deleteReadMarksFromUser($user)
deletes the read markers for the specified user
Source:

lib/private/Comments/Manager.php#1085

Parameters:
Returns:

bool

Since:

9.0.0

public OC\Comments\Manager::setReadMark($objectType, $objectId, $dateTime, $user)
sets the read marker for a given file to the specified date for the
provided user
Source:

lib/private/Comments/Manager.php#1113

Parameters:
  • $objectType (string)
  • $objectId (string)
  • $dateTime (DateTime)
  • $user (OCP\IUser)
Since:

9.0.0

public OC\Comments\Manager::getReadMark($objectType, $objectId, $user)
returns the read marker for a given file to the specified date for the
provided user. It returns null, when the marker is not present, i.e.
no comments were marked as read.
Source:

lib/private/Comments/Manager.php#1159

Parameters:
  • $objectType (string)
  • $objectId (string)
  • $user (OCP\IUser)
Returns:

\DateTime | null

Since:

9.0.0

public OC\Comments\Manager::deleteReadMarksOnObject($objectType, $objectId)
deletes the read markers on the specified object
Source:

lib/private/Comments/Manager.php#1188

Parameters:
  • $objectType (string)
  • $objectId (string)
Returns:

bool

Since:

9.0.0

public OC\Comments\Manager::registerEventHandler($closure)
registers an Entity to the manager, so event notifications can be send
to consumers of the comments infrastructure
Source:

lib/private/Comments/Manager.php#1216

Parameters:
  • $closure (Closure)
public OC\Comments\Manager::registerDisplayNameResolver($type, $closure)
registers a method that resolves an ID to a display name for a given type
Source:

lib/private/Comments/Manager.php#1232

Parameters:
  • $type (string)
  • $closure (Closure)
Throws:

\OutOfBoundsException

Since:

11.0.0 Only one resolver shall be registered per type. Otherwise a \OutOfBoundsException has to thrown.

public OC\Comments\Manager::resolveDisplayName($type, $id)
resolves a given ID of a given Type to a display name.
Source:

lib/private/Comments/Manager.php#1255

Parameters:
  • $type (string)
  • $id (string)
Returns:

string

Throws:

\OutOfBoundsException

Since:

11.0.0 If a provided type was not registered, an \OutOfBoundsException shall be thrown. It is upon the resolver discretion what to return of the provided ID is unknown. It must be ensured that a string is returned.

public OC\Comments\Manager::load()
Load the Comments app into the page
Source:lib/private/Comments/Manager.php#1306
Since:21.0.0