1

I'm programmatically creating a new node using Entity Metadata Wrapper.

How to check if last instruction:

$ewrapper->save();

creates correctly the new node without errors?

1
4

Check that the entity has an identifier:

if ($ewrapper->getIdentifier()) {
  // Save happened.
}

A better approach might be handling any errors:

try {
  $ewrapper->save();

  // Try to do something with $ewrapper->getIdentifier()
}
catch (\Exception $e) {
  // Recover...
}
1

Try to chech the following: $wrapper->getIdentifier(), it should return nid of new node.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.