function ModeratedNodeResourceTestBase::createEntity

Same name in other branches
  1. 9 core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\ModeratedNode\ModeratedNodeResourceTestBase::createEntity()
  2. 8.9.x core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\ModeratedNode\ModeratedNodeResourceTestBase::createEntity()
  3. 11.x core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\ModeratedNode\ModeratedNodeResourceTestBase::createEntity()

Overrides NodeResourceTestBase::createEntity

File

core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeResourceTestBase.php, line 48

Class

ModeratedNodeResourceTestBase
Extend the Node resource test base and apply moderation to the entity.

Namespace

Drupal\Tests\rest\Functional\EntityResource\ModeratedNode

Code

protected function createEntity() {
    $entity = parent::createEntity();
    if (!$this->workflow) {
        $this->workflow = $this->createEditorialWorkflow();
    }
    $this->workflow
        ->getTypePlugin()
        ->addEntityTypeAndBundle($entity->getEntityTypeId(), $entity->bundle());
    $this->workflow
        ->save();
    return $entity;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.