/** * {@inheritdoc} */ public function createNewEntity($entity_type_id, $bundle, $label, $uid) { $comment = parent::createNewEntity($entity_type_id, $bundle, $label, $uid); // In order to create a referenceable comment, it needs to published. /** @var \Drupal\comment\CommentInterface $comment */ $comment->setPublished(TRUE); return $comment; }
/** * {@inheritdoc} */ public function createNewEntity($entity_type_id, $bundle, $label, $uid) { $node = parent::createNewEntity($entity_type_id, $bundle, $label, $uid); // In order to create a referenceable node, it needs to published. /** @var \Drupal\node\NodeInterface $node */ $node->setPublished(TRUE); return $node; }
/** * {@inheritdoc} */ public function createNewEntity($entity_type_id, $bundle, $label, $uid) { $file = parent::createNewEntity($entity_type_id, $bundle, $label, $uid); // In order to create a referenceable file, it needs to have a "permanent" // status. /** @var \Drupal\file\FileInterface $file */ $file->setPermanent(); return $file; }
/** * {@inheritdoc} */ public function createNewEntity($entity_type_id, $bundle, $label, $uid) { $user = parent::createNewEntity($entity_type_id, $bundle, $label, $uid); // In order to create a referenceable user, it needs to be active. if (!$this->currentUser->hasPermission('administer users')) { /** @var \Drupal\user\UserInterface $user */ $user->activate(); } return $user; }