+ /**
+ * Default value callback for 'status' base field definition.
+ *
+ * @see ::baseFieldDefinitions()
+ *
+ * @return bool
+ * TRUE if the comment should be published, FALSE otherwise.
+ */
+ public static function getDefaultStatus() {
+ return \Drupal::currentUser()->hasPermission('skip comment approval') ? CommentInterface::PUBLISHED : CommentInterface::NOT_PUBLISHED;
+ }
+
+ /**
+ * Returns the default value for entity hostname base field.
+ *
+ * @return string
+ * The client host name.
+ */
+ public static function getDefaultHostname() {
+ return \Drupal::request()->getClientIP();
+ }
+