public function actionImport() { $this->requirePostRequest(); $json = craft()->request->getParam('data', '{}'); $data = ArtVandelay_ExportedDataModel::fromJson($json); $result = new ArtVandelay_ResultModel(); if ($data !== null) { $assetImportResult = craft()->artVandelay_assets->import($data->assets); $categoryImportResult = craft()->artVandelay_categories->import($data->categories); $fieldImportResult = craft()->artVandelay_fields->import($data->fields); $globalImportResult = craft()->artVandelay_globals->import($data->globals); $sectionImportResult = craft()->artVandelay_sections->import($data->sections); $tagImportResult = craft()->artVandelay_tags->import($data->tags); $result->consume($assetImportResult); $result->consume($categoryImportResult); $result->consume($fieldImportResult); $result->consume($globalImportResult); $result->consume($sectionImportResult); $result->consume($tagImportResult); if ($result->ok) { craft()->userSession->setNotice('All done.'); $this->redirectToPostedUrl(); return; } } else { $errors[] = 'Invalid JSON.'; } craft()->userSession->setError('Get *out*! ' . implode(', ', $result->errors)); craft()->urlManager->setRouteVariables(array('groupOptions' => $this->_getGroupOptions(), 'entryTypeOptions' => $this->_getEntryTypeOptions())); }
public function loadFromJson($json) { $data = ArtVandelay_ExportedDataModel::fromJson($json); foreach ($data->fields as $group) { $group['notes'] = "HEY"; } return $data; }