public function PrivateMessageThread::delete in Private Message 8
Same name and namespace in other branches
- 8.2 src/Entity/PrivateMessageThread.php \Drupal\private_message\Entity\PrivateMessageThread::delete()
Deletes an entity permanently.
Throws
\Drupal\Core\Entity\EntityStorageException In case of failures an exception is thrown.
Overrides EntityBase::delete
File
- src/
Entity/ PrivateMessageThread.php, line 278
Class
- PrivateMessageThread
- Defines the Private Message Thread entity.
Namespace
Drupal\private_message\EntityCode
public function delete(AccountInterface $account = NULL) {
if ($account) {
$this
->updateLastDeleteTime($account);
$last_creation_timestamp = $this
->getNewestMessageCreationTimestamp();
$delete = TRUE;
$last_delete_times = $this
->getLastDeleteTimes();
foreach ($last_delete_times as $last_delete_time) {
if ($last_delete_time
->getDeleteTime() < $last_creation_timestamp) {
$delete = FALSE;
break;
}
}
if ($delete) {
$this
->deleteReferencedEntities();
parent::delete();
}
}
else {
$this
->deleteReferencedEntities();
parent::delete();
}
$this
->clearCacheTags();
}