$save = false;
$host = $context->getOne('ContextSettings',array('key'=>'http_host'));
if($host == null){
$host = $modx->newObject('modContextSetting',array(
'key' => 'http_host',
'value' => '',
'namespace' => 'modx'
));
$context->addOne($host);
$save = true;
}
$alias = $context->getOne('ContextSettings',array('key'=>'http_host_aliases'));
if($alias == null){
$alias = $modx->newObject('modContextSetting',array(
'key' => 'http_host_aliases',
'value' => '',
'namespace' => 'modx'
));
$context->addOne($alias);
$save = true;
}
if($save === true) $context->save();
The problem is, that neither of ContextSettings which are created and added to context as $context->addOne() arent saved when i save $context->save();
Do i need to call the save() function for each of the child? Or is this somehow connected with the fact that relationship is one->many?
Sumoborac