Created
May 25, 2016 20:54
-
-
Save batigolix/be2feac4b346ea009733ec37ed6c5239 to your computer and use it in GitHub Desktop.
Update drupal 8 node and save
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Drupal\node\Entity\Node; | |
function _svv_tools_set_author() { | |
$user = user_load_by_name('test'); | |
$query = \Drupal::entityQuery('node'); | |
$nids = $query->execute(); | |
dd($nids); | |
foreach ($nids as $nid) { | |
$node = Node::load($nid); | |
$node->uid->value = $user->id(); | |
$node->save(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment