[...]
$resources[2]->fromArray(array(
'id' => 2,
'class_key' => 'modResource',
'context_key' => 'web',
'type' => 'document',
'contentType' => 'text/css',
'pagetitle' => 'style',
[...]
$resourceObject->set('contentType', 'text/css');
[...]
$attributes= array(
xPDOTransport::PRESERVE_KEYS => false,
xPDOTransport::UPDATE_OBJECT => true,
xPDOTransport::UNIQUE_KEY => 'pagetitle',
xPDOTransport::RELATED_OBJECTS => true,
xPDOTransport::RELATED_OBJECT_ATTRIBUTES => array (
'ContentType' => array(
xPDOTransport::PRESERVE_KEYS => false,
xPDOTransport::UPDATE_OBJECT => true,
xPDOTransport::UNIQUE_KEY => 'name',
),
),
[...]
This question has been answered by webknot. See the first response.
'contentType' => 'css',
$resources[2] = $modx->newObject('modResource');
$resources[2]->fromArray(array(
'id' => 2,
'class_key' => 'modResource',
'context_key' => 'web',
'type' => 'document',
'contentType' => 'text/css',
'content_type' => '4',
'pagetitle' => 'style',case 'contentType' :
if ($v !== $this->get('contentType')) {
if ($contentType= $this->xpdo->getObject('modContentType', array ('mime_type' => $v))) {
if ($contentType->get('mime_type') != $this->get('contentType')) {
$this->addOne($contentType, 'ContentType');
}
}
}
break;
case 'content_type' :
if ($v !== $this->get('content_type')) {
/** @var modContentType $contentType */
if ($contentType= $this->xpdo->getObject('modContentType', $v)) {
if ($contentType->get('mime_type') != $this->get('contentType')) {
$this->_fields['contentType']= $contentType->get('mime_type');
$this->_dirty['contentType']= 'contentType';
}
}
}