public function iHaveTheFollowingNodes($table)
{
if ($this->isolated === true) {
$this->callStepInSubProcess(__METHOD__, sprintf(' %s %s', escapeshellarg(\Neos\Flow\Tests\Functional\Command\TableNode::class), escapeshellarg(json_encode($table->getHash()))), true);
} else {
/** @var \Neos\ContentRepository\Domain\Service\NodeTypeManager $nodeTypeManager */
$nodeTypeManager = $this->getObjectManager()->get(\Neos\ContentRepository\Domain\Service\NodeTypeManager::class);
$rows = $table->getHash();
foreach ($rows as $row) {
$path = $row['Path'];
$name = implode('', array_slice(explode('/', $path), -1, 1));
$parentPath = implode('/', array_slice(explode('/', $path), 0, -1)) ?: '/';
$context = $this->getContextForProperties($row, true);
if (isset($row['Node Type']) && $row['Node Type'] !== '') {
$nodeType = $nodeTypeManager->getNodeType($row['Node Type']);
} else {
$nodeType = null;
}
if (isset($row['Identifier'])) {
$identifier = $row['Identifier'];
} else {
$identifier = null;
}
if (isset($row['Hidden']) && $row['Hidden'] === 'true') {
$hidden = true;
} else {
$hidden = false;
}
$parentNode = $context->getNode($parentPath);
if ($parentNode === null) {
throw new \Exception(sprintf('Could not get parent node with path %s to create node %s', $parentPath, $path));
}
$node = $parentNode->createNode($name, $nodeType, $identifier);
if (isset($row['Properties']) && $row['Properties'] !== '') {
$properties = json_decode($row['Properties'], true);
if ($properties === null) {
throw new \Exception(sprintf('Error decoding json value "%s": %d', $row['Properties'], json_last_error()));
}
foreach ($properties as $propertyName => $propertyValue) {
$node->setProperty($propertyName, $propertyValue);
}
}
$node->setHidden($hidden);
}
// Make sure we do not use cached instances
$this->objectManager->get(\Neos\Flow\Persistence\PersistenceManagerInterface::class)->persistAll();
$this->resetNodeInstances();
}
}