Devise
Class

Devise\Sidebar\EditorDataTranslator

class EditorDataTranslator

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, CollectionsManager $CollectionsManager)

EditorData translateFromInputArray(array $inputData)

Structures the data for the editor from array input

Details

at line 68
public __construct(FieldManager $FieldManager, CollectionsManager $CollectionsManager)

Parameters

FieldManager $FieldManager
CollectionsManager $CollectionsManager

at line 80
public EditorData translateFromInputArray(array $inputData)

Structures the data for the editor from array input

Parameters

array $inputData

Return Value

EditorData