//Best Practice user ID in parameters.yml
//@deprecated since 6.6 to be removed:
//$repository->setCurrentUser($repository->getUserService()->loadUserByLogin( 'admin' ));
//$repository->setCurrentUser( $repository->getUserService()->loadUser( 14 ) );
Use now:
$repository->getPermissionResolver()->setCurrentUserReference( $repository->getUserService()->loadUser( 14 ) );
$contentCreateStruct->setField('title', 'text');
$contentCreateStruct->setField('photo', '/data/image.jpg');
or
$value = new \eZ\Publish\Core\FieldType\Image\Value(
array(
'path' => $file,
'fileSize' => filesize( $file ),
'fileName' => basename( $file ),
'alternativeText' => $name
)
);
$contentCreateStruct->setField( 'image', $value );
$body = '<?xml version="1.0" encoding="UTF-8"?>
<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ezxhtml="http://ez.no/xmlns/ezpublish/docbook/xhtml" xmlns:ezcustom="http://ez.no/xmlns/ezpublish/docbook/custom" version="5.0-variant ezpublish-1.0"><para>'.utf8_encode(trim($data)).'</para></section>';
$contentCreateStruct->setField('starting_point',array(
'address' => $address,
'latitude' => (float) $latitude,
'longitude' => (float) $longitude
)
);
$contentCreateStruct->setField('length',(int) $value);
0: first occurrence in the selection list
$contentCreateStruct->setField('difficulty',array(
'selection' => 0
)
);