@@ -55,27 +55,26 @@ public function importLesson(array $data, $rootPath)
55
55
$ lessonData = $ data ['data ' ];
56
56
57
57
$ chaptersMap = array ();
58
- foreach ($ lessonData as $ chapter ) {
59
- $ chapterData = $ chapter ['chapter ' ];
58
+ foreach ($ lessonData ['chapters ' ] as $ chapter ) {
60
59
$ entityChapter = new Chapter ();
61
60
$ entityChapter ->setLesson ($ lesson );
62
- $ entityChapter ->setTitle ($ chapterData ['title ' ]);
61
+ $ entityChapter ->setTitle ($ chapter ['title ' ]);
63
62
$ text = file_get_contents (
64
- $ rootPath . DIRECTORY_SEPARATOR . $ chapterData ['path ' ]
63
+ $ rootPath . DIRECTORY_SEPARATOR . $ chapter ['path ' ]
65
64
);
66
65
$ entityChapter ->setText ($ text );
67
- if ($ chapterData ['is_root ' ]) {
66
+ if ($ chapter ['is_root ' ]) {
68
67
$ lesson ->setRoot ($ entityChapter );
69
68
}
70
69
$ parentChapter = null ;
71
- if ($ chapterData ['parent_id ' ] !== null ) {
72
- $ parentChapter = $ chaptersMap [$ chapterData ['parent_id ' ]];
70
+ if ($ chapter ['parent_id ' ] !== null ) {
71
+ $ parentChapter = $ chaptersMap [$ chapter ['parent_id ' ]];
73
72
$ entityChapter ->setParent ($ parentChapter );
74
73
$ this ->chapterRepository ->persistAsLastChildOf ($ entityChapter , $ parentChapter );
75
74
} else {
76
75
$ this ->chapterRepository ->persistAsFirstChild ($ entityChapter );
77
76
}
78
- $ chaptersMap [$ chapterData ['id ' ]] = $ entityChapter ;
77
+ $ chaptersMap [$ chapter ['id ' ]] = $ entityChapter ;
79
78
}
80
79
}
81
80
@@ -93,7 +92,7 @@ public function importLesson(array $data, $rootPath)
93
92
*/
94
93
public function exportLesson (Workspace $ workspace , array &$ files , Lesson $ object )
95
94
{
96
- $ data = array ();
95
+ $ data = array (' chapters ' => array () );
97
96
98
97
// Getting all sections and building array
99
98
$ rootChapter = $ object ->getRoot ();
@@ -113,9 +112,7 @@ public function exportLesson(Workspace $workspace, array &$files, Lesson $object
113
112
'path ' => $ uid
114
113
);
115
114
116
- $ data [] = array (
117
- 'chapter ' => $ chapterArray
118
- );
115
+ $ data ['chapters ' ][] = $ chapterArray ;
119
116
}
120
117
121
118
return $ data ;
0 commit comments