function RESTTestBase::removeNodeFieldsForNonAdminUsers

Remove node fields that can only be written by an admin user.

Parameters

\Drupal\node\NodeInterface $node: The node to remove fields where non-administrative users cannot write.

Return value

\Drupal\node\NodeInterface The node with removed fields.

File

core/modules/rest/src/Tests/RESTTestBase.php, line 550

Class

RESTTestBase
Test helper class that provides a REST client method to send HTTP requests.

Namespace

Drupal\rest\Tests

Code

protected function removeNodeFieldsForNonAdminUsers(NodeInterface $node) {
    $node->set('status', NULL);
    $node->set('created', NULL);
    $node->set('changed', NULL);
    $node->set('promote', NULL);
    $node->set('sticky', NULL);
    $node->set('revision_timestamp', NULL);
    $node->set('revision_log', NULL);
    $node->set('uid', NULL);
    return $node;
}

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