diff --git a/Core/Executor/ContentManager.php b/Core/Executor/ContentManager.php
index ce24b6a3..ac702372 100644
--- a/Core/Executor/ContentManager.php
+++ b/Core/Executor/ContentManager.php
@@ -270,24 +270,37 @@ protected function matchContents($action)
*
* @param ContentCreateStruct|ContentUpdateStruct $createOrUpdateStruct
* @param ContentType $contentType
- * @param array $fields
+ * @param array $fields see description of expected format in code below
* @throws \Exception
*/
protected function setFields($createOrUpdateStruct, array $fields, ContentType $contentType)
{
- foreach ($fields as $field) {
- // each $field is one key value pair
- // eg.: $field = array($fieldIdentifier => $fieldValue)
- $fieldIdentifier = key($field);
+ $i = 0;
+ // the 'easy' yml: key = field name, value = value
+ // deprecated: the 'legacy' yml: key = numerical index, value = array ( field name => value )
+ foreach ($fields as $key => $field) {
+
+ if ($key === $i && is_array($field) && count($field) == 1) {
+ // each $field is one key value pair
+ // eg.: $field = array($fieldIdentifier => $fieldValue)
+ reset($field);
+ $fieldIdentifier = key($field);
+ $fieldValue = $field[$fieldIdentifier];
+ } else {
+ $fieldIdentifier = $key;
+ $fieldValue = $field;
+ }
$fieldType = $contentType->fieldDefinitionsByIdentifier[$fieldIdentifier];
if ($fieldType == null) {
throw new \Exception("Field '$fieldIdentifier' is not present in field type '{$contentType->identifier}'");
}
- $fieldValue = $this->getFieldValue($field[$fieldIdentifier], $fieldType, $contentType->identifier, $this->context);
+ $fieldValue = $this->getFieldValue($fieldValue, $fieldType, $contentType->identifier, $this->context);
$createOrUpdateStruct->setField($fieldIdentifier, $fieldValue, $this->getLanguageCode());
+
+ $i++;
}
}
diff --git a/Resources/doc/DSL/ManageContent.yml b/Resources/doc/DSL/ManageContent.yml
index 7495971d..2dd37c1b 100644
--- a/Resources/doc/DSL/ManageContent.yml
+++ b/Resources/doc/DSL/ManageContent.yml
@@ -15,37 +15,37 @@
owner: xxx # user id, login or email if unique; Optional, set the content owner
modification_date: zzz # Optional, set content modification date (for formats, see: http://php.net/manual/en/datetime.formats.php)
attributes:
- - attribute1: value1
- - attribute2: value2
- - attribute3: |
- value can be
- on multiple lines
- and new lines are preserved on parsing
- - attribute4: >
- value on multiple
- lines, but new line is not preserved on parsing
+ attribute1: value1
+ attribute2: value2
+ attribute3: |
+ value can be
+ on multiple lines
+ and new lines are preserved on parsing
+ attribute4: >
+ value on multiple
+ lines, but new line is not preserved on parsing
# ezimage/ezbinaryfile file attribute example
- - attribute5:
+ attribute5:
path: 'path/to/image' # Relative path from MigrationsVersions/images/ or MigrationsVersions/files/
alt_text: xyz # Optional, only used for images
filename: abc # Optional, taken from the actual file if not specified
mime_type: def # Optional. For ezbinaryfile only. If not specified, the actual file is analyzed using the php function mime_content_type()
# ezimage/ezbinaryfile file attribute example, using simplified form
- - attribute5b: 'path/to/image'
+ attribute5b: 'path/to/image'
# ezxmltext, showing an example of using references
- - attribute6: ''
+ attribute6: ''
# Adding values to an ezauthor field
- - attribute7:
- -
- name: Test Author
- email: test@example.com
- -
- name: Another Author
- email: another@example.com
+ attribute7:
+ -
+ name: Test Author
+ email: test@example.com
+ -
+ name: Another Author
+ email: another@example.com
# Adding values to an ezobjectrelation field
- - attribute8: x # content id or string: reference:xxx
+ attribute8: x # content id or string: reference:xxx
# Adding values to an ezobjectrelationlist field
- - ezobjectrelationlist: [ x, reference:xxx ] # array of content ids or reference strings
+ ezobjectrelationlist: [ x, reference:xxx ] # array of content ids or reference strings
# Optionally assign object states to the content
object_states:
- xxx # int|string an object state id or identifier. If the identifier is not unique, use obj-state-gorup-identifier/obj-state-identifier
@@ -75,8 +75,8 @@
publication_date: zzz # Optional, set content modification date (for formats, see: http://php.net/manual/en/datetime.formats.php)
new_remote_id: xxx # string Optional set a new RemoteId
attributes: # the list of attribute identifier value pairs. For the format to use, see above
- - attribute1: value1
- - attribute2: value2
+ attribute1: value1
+ attribute2: value2
# Optionally assign object states to the content
object_states:
- xxx # int|string an object state id or didentifier. For the format to use, see above
diff --git a/Resources/doc/DSL/ManageObjectStatesAndGoups.yml b/Resources/doc/DSL/ManageObjectStatesAndGoups.yml
index dffeec38..a8768799 100644
--- a/Resources/doc/DSL/ManageObjectStatesAndGoups.yml
+++ b/Resources/doc/DSL/ManageObjectStatesAndGoups.yml
@@ -3,13 +3,13 @@
type: object_state_group
identifier: x # String identifier of the object state group
names: # Array of names keyed by language code.
- - languageCodeA: name
- - languageCodeB: name
+ languageCodeA: name
+ languageCodeB: name
descriptions: # Optional: array of descriptions keyed by language code.
- - languageCodeA: description
- - languageCodeB: description
+ languageCodeA: description
+ languageCodeB: description
references: #Optional
- -
+ -
identifier: referenceId # A string used to identify the reference
attribute: attribute # An attribute to get the value of for the reference; supported: object_state_group_id, object_state_group_identifier
# The shorthand 'id' can be used instead of 'object_state_group_id'
@@ -22,13 +22,13 @@
identifier: y # string|string[] The Identifier of the object state group(s) to update
identifier: x # Optional String: new identifier of the object state group
names: # Optional: array of names keyed by language code.
- - languageCodeA: name
- - languageCodeB: name
+ languageCodeA: name
+ languageCodeB: name
descriptions: # Optional: array of descriptions keyed by language code.
- - languageCodeA: description
- - languageCodeB: description
+ languageCodeA: description
+ languageCodeB: description
references: #Optional
- -
+ -
identifier: referenceId # A string used to identify the reference
attribute: attribute # An attribute to get the value of for the reference; supported: object_state_group_id, object_state_group_identifier
# The shorthand 'id' can be used instead of 'object_state_group_id'
@@ -48,13 +48,13 @@
object_state_group: x # The Id of the object state group the new state will be created under.
identifier: xyz # The string identifier of the new object state.
names: # Array of names keyed by language code.
- - languageCodeA: name
- - languageCodeB: name
+ languageCodeA: name
+ languageCodeB: name
descriptions: # Optional: array of descriptions keyed by language code.
- - languageCodeA: description
- - languageCodeB: description
+ languageCodeA: description
+ languageCodeB: description
references: #Optional
- -
+ -
identifier: referenceId # A string used to identify the reference
attribute: attribute # An attribute to get the value of for the reference (currently supports object_state_id)
# The shorthand 'id' can be used instead of 'object_state_id'
@@ -67,13 +67,13 @@
identifier: x # string|string[] The string identifier of the object state to update. If the identifier is not unique, use group-identifier/state-identifier
identifier: x # Optional String: new identifier of the object state
names: # Optional: array of names keyed by language code.
- - languageCodeA: name
- - languageCodeB: name
+ languageCodeA: name
+ languageCodeB: name
descriptions: # Optional: array of descriptions keyed by language code.
- - languageCodeA: description
- - languageCodeB: description
+ languageCodeA: description
+ languageCodeB: description
references: #Optional
- -
+ -
identifier: referenceId # A string used to identify the reference
attribute: attribute # An attribute to get the value of for the reference (currently supports object_state_id)
# The shorthand 'id' can be used instead of 'object_state_id'
diff --git a/Tests/dsl/good/UnitTestOK004_content.yml b/Tests/dsl/good/UnitTestOK004_content.yml
index 1d1e546f..201e6560 100644
--- a/Tests/dsl/good/UnitTestOK004_content.yml
+++ b/Tests/dsl/good/UnitTestOK004_content.yml
@@ -163,7 +163,7 @@
sort_order: DESC
modification_date: "2006:07:08 18:11:31"
attributes:
- - ezstring: hello world 3
+ ezstring: hello world 3
references:
-
identifier: kmb_test_2_3
diff --git a/Tests/dsl/good/UnitTestOK012_objectState.yml b/Tests/dsl/good/UnitTestOK012_objectState.yml
index c19ecc33..d7944006 100644
--- a/Tests/dsl/good/UnitTestOK012_objectState.yml
+++ b/Tests/dsl/good/UnitTestOK012_objectState.yml
@@ -8,7 +8,7 @@
eng-GB: Kaliop Migration Bundle Test Object State Group 1
roles: [1, 2] # Anon, admin
references:
- -
+ -
identifier: kmb_test_12
attribute: id
@@ -29,7 +29,7 @@
descriptions:
eng-GB: Kaliop Migration Bundle Test Object State 1
references:
- -
+ -
identifier: kmb_test_12_state
attribute: id
diff --git a/WHATSNEW.md b/WHATSNEW.md
index f01826df..b56ec6ba 100644
--- a/WHATSNEW.md
+++ b/WHATSNEW.md
@@ -74,6 +74,9 @@ Version 3.0.0-beta3
* Changes to the YML definition language:
+ * Creation and update of content: the format use to specify the attributes has been simplified. The old format is
+ still working but is considered deprecated and will be removed in the future
+
* Updating and deleting of Users, User Groups, Roles and Content Types: usage of a `match` key is allowed; previous
ways of defining elements to match are deprecated