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
  • how about simpletest? Commented Sep 16, 2015 at 10:32

2 Answers 2

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.