/**
* The thread for which a lock was acquired.
*
* @var string
*/
protected $threadLock = '';
/**
* {@inheritdoc}
*/
public function preSave(EntityStorageInterface
$storage) { parent::
preSave($storage);
if ($this->
isNew()) { // Add the comment to database. This next section builds the thread field.
// @see \Drupal\comment\CommentViewBuilder::buildComponents()
$thread =
$this->
getThread();
if (empty($thread)) { if ($this->threadLock
) { // Thread lock was not released after being set previously.
// This suggests there's a bug in code using this class.
throw new \
LogicException('preSave() is called again without calling postSave() or releaseThreadLock()'
);
}