44
55use Illuminate \Database \Eloquent \Model ;
66use Illuminate \Support \Str ;
7+ use SolutionForest \InspireCms \Helpers \ImportDataHelper ;
78use SolutionForest \InspireCms \Helpers \TemplateHelper ;
89use SolutionForest \InspireCms \ImportData \Entities as ImportDataEntities ;
910use SolutionForest \InspireCms \Models \Contracts \Content ;
1011use SolutionForest \InspireCms \Models \Contracts \DocumentType ;
1112use SolutionForest \InspireCms \Models \Contracts \FieldGroup ;
13+ use SolutionForest \InspireCms \Models \Contracts \Navigation ;
1214use SolutionForest \InspireCms \Models \Contracts \Template ;
1315
1416abstract class BaseImportUsedDataExporter extends BaseExporter
@@ -52,12 +54,12 @@ protected function prepareImportContentFromModel(Model $record)
5254 switch (true ) {
5355
5456 case $ record instanceof DocumentType:
55- $ array = ImportDataEntities \DocumentType::fromRecord ($ record )->toExportArray ();
57+ $ array = ImportDataEntities \DocumentType::fromRecord ($ record )->toArray ();
5658
5759 return json_encode ($ array , JSON_PRETTY_PRINT );
5860
5961 case $ record instanceof FieldGroup:
60- $ array = ImportDataEntities \FieldGroup::fromRecord ($ record )->toExportArray ();
62+ $ array = ImportDataEntities \FieldGroup::fromRecord ($ record )->toArray ();
6163
6264 return json_encode ($ array , JSON_PRETTY_PRINT );
6365
@@ -69,12 +71,18 @@ protected function prepareImportContentFromModel(Model $record)
6971 // return $themeContent;
7072
7173 case $ record instanceof Content:
72- $ array = ImportDataEntities \Content::fromRecord ($ record )->toExportArray ();
74+ $ array = ImportDataEntities \Content::fromRecord ($ record )->toArray ();
75+
76+ return json_encode ($ array , JSON_PRETTY_PRINT );
77+
78+ case $ record instanceof Navigation:
79+
80+ $ array = ImportDataEntities \Navigation::fromRecord ($ record )->toArray ();
7381
7482 return json_encode ($ array , JSON_PRETTY_PRINT );
7583 }
7684
77- return '' ;
85+ return '{} ' ;
7886 }
7987
8088 protected function processRecordForImportUsed (Model $ record , $ fs , ?string $ dir , array &$ errors )
@@ -117,4 +125,45 @@ protected function processRecordForImportUsed(Model $record, $fs, ?string $dir,
117125 ];
118126 }
119127 }
128+
129+ /**
130+ * @param \Illuminate\Database\Eloquent\Builder $query
131+ * @param string $type
132+ * @return \Illuminate\Database\Eloquent\Builder
133+ */
134+ protected function buildExportingQueryForImportUsed ($ query , $ type )
135+ {
136+ switch ($ type ) {
137+ case ImportDataHelper::FOLDER_IDENTIFIER_DOCUMENTTYPE :
138+ return $ query ->with ([
139+ 'fieldGroups ' ,
140+ 'templates ' ,
141+ 'allowedDocumentTypes ' ,
142+ 'content ' ,
143+ ]);
144+ case ImportDataHelper::FOLDER_IDENTIFIER_FIELDGROUP :
145+ return $ query ->with ([
146+ 'fields ' ,
147+ ]);
148+ case ImportDataHelper::FOLDER_IDENTIFIER_CONTENT :
149+ return $ query ->with ([
150+ 'parent.path ' ,
151+ 'sitemap ' ,
152+ 'webSetting ' ,
153+ 'documentType ' ,
154+ ]);
155+ }
156+
157+ return $ query ;
158+ }
159+
160+ protected static function buildProcessingDataForImportUsed (int $ currentPage , int $ perPage , array $ errors , string $ folderName )
161+ {
162+ return [
163+ 'page ' => $ currentPage + 1 ,
164+ 'perPage ' => $ perPage ,
165+ 'errors ' => $ errors ,
166+ 'folderName ' => $ folderName ,
167+ ];
168+ }
120169}
0 commit comments