class SidebarDataTranslator
The translator's job is to translate input into something we can use for our views and other places.
This translator will also validate our input to ensure that things are still sane - so for example if you leave certain fields out then we cannot translate the babble. Here is an example of the data coming in from inputData.
array(4) {
["coordinates"]=> array(2) {
["top"]=> string(3) "647"
["left"]=> string(5) "101.5"
}
["categoryName"] => string(8) "Headings"
["categoryCount"] => string(1) "3"
["groups"]=> array(3) {
["Heading 1"]=> array(3) {
[0]=> array(3) { ["key"]=> string(5) "title" ["type"]=> string(4) "text" ["humanName"]=> string(5) "Title" }
[1]=> array(3) { ["key"]=> string(5) "title" ["type"]=> string(4) "text" ["humanName"]=> string(5) "Title" }
[2]=> array(3) { ["key"]=> string(5) "title" ["type"]=> string(4) "text" ["humanName"]=> string(5) "Title" }
}
["Heading 2"]=> array(3) {
[0]=> array(3) { ["key"]=> string(5) "title" ["type"]=> string(4) "text" ["humanName"]=> string(5) "Title" }
[1]=> array(3) { ["key"]=> string(5) "title" ["type"]=> string(4) "text" ["humanName"]=> string(5) "Title" }
[2]=> array(3) { ["key"]=> string(5) "title" ["type"]=> string(4) "text" ["humanName"]=> string(5) "Title" }
}
["Heading 3"]=> array(3) {
[0]=> array(3) { ["key"]=> string(5) "title" ["type"]=> string(4) "text" ["humanName"]=> string(5) "Title" }
[1]=> array(3) { ["key"]=> string(5) "title" ["type"]=> string(4) "text" ["humanName"]=> string(5) "Title" }
[2]=> array(3) { ["key"]=> string(5) "title" ["type"]=> string(4) "text" ["humanName"]=> string(5) "Title" }
}
}
}
Here is an example of the data coming in from inputData when a collection is requested.
array(4) {
["coordinates"]=> array(2) {
["top"]=> string(3) "647"
["left"]=> string(5) "101.5"
}
["categoryName"] => string(8) "Headings"
["categoryCount"] => string(1) "3"
["collection"]=> array(3) "towers"
["towers"]=> array(3) {
[0]=> array(3) { ["key"]=> string(5) "title" ["type"]=> string(4) "text" ["humanName"]=> string(5) "Title" }
[1]=> array(3) { ["key"]=> string(5) "color" ["type"]=> string(4) "text" ["humanName"]=> string(5) "Title" }
[2]=> array(3) { ["key"]=> string(5) "wysiwyg" ["type"]=> string(4) "text" ["humanName"]=> string(5) "Title" }
}
}
It is our responsibility to translate this array data into a SidebarData format which is a little more structured and behaves more like an object than array. Thus in our views we can access $data->coordinates->top instead of having to check for existence like isset($data['coordinates']['top']) ? $data['coordinates']['top']
Methods
|
__construct(FieldManager $FieldManager, DvsCollectionSet $CollectionSet, CollectionsRepository $CollectionsRepository)
Create a new SidebarData Translator |
||
| SidebarData |
translateFromInputArray(array $inputData)
Structures the data for the editor from array input |
|
| SidebarData |
translateCollectionData(array $inputData)
Tranlates the input data array that has collection data in it into a SidebarData object |
Details
at line 78
public
__construct(FieldManager $FieldManager, DvsCollectionSet $CollectionSet, CollectionsRepository $CollectionsRepository)
Create a new SidebarData Translator
at line 91
public SidebarData
translateFromInputArray(array $inputData)
Structures the data for the editor from array input
at line 160
public SidebarData
translateCollectionData(array $inputData)
Tranlates the input data array that has collection data in it into a SidebarData object