| @@ 55-84 (lines=30) @@ | ||
| 52 | return $group; |
|
| 53 | } |
|
| 54 | ||
| 55 | protected function update($step) |
|
| 56 | { |
|
| 57 | $groupsCollection = $this->matchContentTypeGroups('update', $step); |
|
| 58 | ||
| 59 | if (count($groupsCollection) > 1 && array_key_exists('references', $step->dsl)) { |
|
| 60 | throw new \Exception("Can not execute Content Type Group update because multiple types match, and a references section is specified in the dsl. References can be set when only 1 matches"); |
|
| 61 | } |
|
| 62 | ||
| 63 | $contentTypeService = $this->repository->getContentTypeService(); |
|
| 64 | ||
| 65 | foreach ($groupsCollection as $key => $contentTypeGroup) { |
|
| 66 | $updateStruct = $contentTypeService->newContentTypeGroupUpdateStruct(); |
|
| 67 | ||
| 68 | if (isset($step->dsl['identifier'])) { |
|
| 69 | $updateStruct->identifier = $this->referenceResolver->resolveReference($step->dsl['identifier']); |
|
| 70 | } |
|
| 71 | if (isset($step->dsl['modification_date'])) { |
|
| 72 | $updateStruct->modificationDate = $this->toDateTime($step->dsl['modification_date']); |
|
| 73 | } |
|
| 74 | ||
| 75 | $contentTypeService->updateContentTypeGroup($contentTypeGroup, $updateStruct); |
|
| 76 | // reload the group |
|
| 77 | $group = $contentTypeService->loadContentTypeGroup($contentTypeGroup->id); |
|
| 78 | $groupsCollection[$key] = $group; |
|
| 79 | } |
|
| 80 | ||
| 81 | $this->setReferences($groupsCollection, $step); |
|
| 82 | ||
| 83 | return $groupsCollection; |
|
| 84 | } |
|
| 85 | ||
| 86 | protected function delete($step) |
|
| 87 | { |
|
| @@ 67-94 (lines=28) @@ | ||
| 64 | /** |
|
| 65 | * Handles the section update migration action |
|
| 66 | */ |
|
| 67 | protected function update($step) |
|
| 68 | { |
|
| 69 | $sectionCollection = $this->matchSections('update', $step); |
|
| 70 | ||
| 71 | if (count($sectionCollection) > 1 && array_key_exists('references', $step->dsl)) { |
|
| 72 | throw new \Exception("Can not execute Section update because multiple sections match, and a references section is specified in the dsl. References can be set when only 1 section matches"); |
|
| 73 | } |
|
| 74 | ||
| 75 | $sectionService = $this->repository->getSectionService(); |
|
| 76 | foreach ($sectionCollection as $key => $section) { |
|
| 77 | $sectionUpdateStruct = $sectionService->newSectionUpdateStruct(); |
|
| 78 | ||
| 79 | if (isset($step->dsl['identifier'])) { |
|
| 80 | $sectionUpdateStruct->identifier = $this->referenceResolver->resolveReference($step->dsl['identifier']); |
|
| 81 | } |
|
| 82 | if (isset($step->dsl['name'])) { |
|
| 83 | $sectionUpdateStruct->name = $this->referenceResolver->resolveReference($step->dsl['name']); |
|
| 84 | } |
|
| 85 | ||
| 86 | $section = $sectionService->updateSection($section, $sectionUpdateStruct); |
|
| 87 | ||
| 88 | $sectionCollection[$key] = $section; |
|
| 89 | } |
|
| 90 | ||
| 91 | $this->setReferences($sectionCollection, $step); |
|
| 92 | ||
| 93 | return $sectionCollection; |
|
| 94 | } |
|
| 95 | ||
| 96 | /** |
|
| 97 | * Handles the section delete migration action |
|