Creating page nodes programmatically (with content dimensions)

I would like to create page nodes programmatically, i.e. using a CommandController.

I already created page nodes successfully like this:

$this->nodeOperations->create($parentNode, [
    'nodeType' => 'My.Vendor:SomePage',
    'properties' => [
        'title' => 'Example',
        'otherProperty' => 'something'
    ],
], 'into');

My questions are:

  1. Is this “the right” way or is there some kind of official API for this?
  2. I have one content dimension (language) and I would like to create a translation of my created node. How can I do this?
2 Likes