Ejemplo n.º 1
0
 /**
  * {@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;
 }
Ejemplo n.º 2
0
 /**
  * {@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;
 }
Ejemplo n.º 3
0
 /**
  * {@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;
 }
Ejemplo n.º 4
0
 /**
  * {@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;
 }