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 byIComment interface.
Source: Parameters: - $data (array)
Returns: array
-
public
OC\Comments\Manager::
getCommentFromData
($data)¶ Source: Parameters: - $data (array)
Returns:
-
protected
OC\Comments\Manager::
prepareCommentForDatabaseWrite
($comment)¶ - prepares a comment for an insert or update operation after making sureall necessary fields have a value assigned.
Source: Parameters: - $comment (
OCP\Comments\IComment
)
Returns: \OCP\Comments\IComment
returns the same updated IComment instance as provided by parameter for convenienceThrows: \UnexpectedValueException
- $comment (
-
protected
OC\Comments\Manager::
determineTopmostParentId
($id)¶ - returns the topmost parent id of a given comment identified by ID
Source: Parameters: - $id (string)
Returns: string
Throws:
-
protected
OC\Comments\Manager::
updateChildrenInformation
($id, $cDateTime)¶ - updates child information of a comment
Source: Parameters: - $id (string)
- $cDateTime (
DateTime
) the date time of the most recent child
Throws:
-
protected
OC\Comments\Manager::
checkRoleParameters
($role, $type, $id)¶ - Tests whether actor or object type and id parameters are acceptable.Throws exception if not.
Source: Parameters: - $role (string)
- $type (string)
- $id (string)
Throws: \InvalidArgumentException
-
protected
OC\Comments\Manager::
cache
($comment)¶ - run-time caches a comment
Source: Parameters: - $comment (
OCP\Comments\IComment
)
- $comment (
-
protected
OC\Comments\Manager::
uncache
($id)¶ - removes an entry from the comments run time cache
Source: Parameters: - $id (mixed) the comment’s id
-
public
OC\Comments\Manager::
get
($id)¶ - returns a comment instance
Source: Parameters: - $id (string) the ID of the comment
Returns: Throws: Throws: \InvalidArgumentException
Throws: 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: 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: 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 returnedReturns: Since: 9.0.0
-
public
OC\Comments\Manager::
getForObjectSince
($objectType, $objectId, $lastKnownCommentId, $sortDirection=asc, $limit=30, $includeLastKnown=false)¶ Source: 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: Returns:
-
protected
OC\Comments\Manager::
getLastKnownComment
($objectType, $objectId, $id)¶ Source: 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: 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:
-
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: 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:
-
public
OC\Comments\Manager::
getNumberOfCommentsForObject
($objectType, $objectId, $notOlderThan=null, $verb="")¶ Source: 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: 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: 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: 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: 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: Parameters: - $folderId (int)
- $user (
OCP\IUser
)
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 notsaved in the used data storage. Use save() after setting other fieldsof the comment (e.g. message or verb).
Source: 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: Since: 9.0.0
-
public
OC\Comments\Manager::
delete
($id)¶ - permanently deletes the comment specified by the IDWhen the comment has child comments, their parent ID will be changed tothe parent ID of the item that is to be deleted.
Source: Parameters: - $id (string)
Returns: bool
Throws: \InvalidArgumentException
Since: 9.0.0
-
public
OC\Comments\Manager::
save
($comment)¶ - saves the comment permanentlyif the supplied comment has an empty ID, a new entry comment will besaved 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 notexist anymore at this point of time.
Source: Parameters: - $comment (
OCP\Comments\IComment
)
Returns: bool
Throws: Since: 9.0.0
- $comment (
-
protected
OC\Comments\Manager::
insert
($comment)¶ - inserts the provided comment in the database
Source: Parameters: - $comment (
OCP\Comments\IComment
)
Returns: bool
- $comment (
-
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: Parameters: - $comment (
OCP\Comments\IComment
)
Returns: bool
Throws: - $comment (
-
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: 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: 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: Parameters: - $user (
OCP\IUser
)
Returns: bool
Since: 9.0.0
- $user (
-
public
OC\Comments\Manager::
setReadMark
($objectType, $objectId, $dateTime, $user)¶ - sets the read marker for a given file to the specified date for theprovided user
Source: 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 theprovided user. It returns null, when the marker is not present, i.e.no comments were marked as read.
Source: Parameters: - $objectType (string)
- $objectId (string)
- $user (
OCP\IUser
)
Returns: \DateTime
| nullSince: 9.0.0
-
public
OC\Comments\Manager::
deleteReadMarksOnObject
($objectType, $objectId)¶ - deletes the read markers on the specified object
Source: 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 sendto consumers of the comments infrastructure
Source: Parameters: - $closure (
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: 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: 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