| @@ 162-217 (lines=56) @@ | ||
| 159 | * @throws \Exception |
|
| 160 | * @return array |
|
| 161 | */ |
|
| 162 | public function generateMigration(array $matchCondition, $mode, array $context = array()) |
|
| 163 | { |
|
| 164 | $previousUserId = $this->loginUser($this->getAdminUserIdentifierFromContext($context)); |
|
| 165 | $contentTypeGroupCollection = $this->contentTypeGroupMatcher->match($matchCondition); |
|
| 166 | $data = array(); |
|
| 167 | ||
| 168 | /** @var \eZ\Publish\API\Repository\Values\ContentType\ContentTypeGroup $contentTypeGroup */ |
|
| 169 | foreach ($contentTypeGroupCollection as $contentTypeGroup) { |
|
| 170 | ||
| 171 | $contentTypeGroupData = array( |
|
| 172 | 'type' => reset($this->supportedStepTypes), |
|
| 173 | 'mode' => $mode, |
|
| 174 | ); |
|
| 175 | ||
| 176 | switch ($mode) { |
|
| 177 | case 'create': |
|
| 178 | $contentTypeGroupData = array_merge( |
|
| 179 | $contentTypeGroupData, |
|
| 180 | array( |
|
| 181 | 'identifier' => $contentTypeGroup->identifier, |
|
| 182 | 'creation_date' => $contentTypeGroup->creationDate->getTimestamp() |
|
| 183 | ) |
|
| 184 | ); |
|
| 185 | break; |
|
| 186 | case 'update': |
|
| 187 | $contentTypeGroupData = array_merge( |
|
| 188 | $contentTypeGroupData, |
|
| 189 | array( |
|
| 190 | 'match' => array( |
|
| 191 | ContentTypeGroupMatcher::MATCH_CONTENTTYPEGROUP_IDENTIFIER => $contentTypeGroup->identifier |
|
| 192 | ), |
|
| 193 | 'identifier' => $contentTypeGroup->identifier, |
|
| 194 | 'modification_date' => $contentTypeGroup->modificationDate->getTimestamp() |
|
| 195 | ) |
|
| 196 | ); |
|
| 197 | break; |
|
| 198 | case 'delete': |
|
| 199 | $contentTypeGroupData = array_merge( |
|
| 200 | $contentTypeGroupData, |
|
| 201 | array( |
|
| 202 | 'match' => array( |
|
| 203 | ContentTypeGroupMatcher::MATCH_CONTENTTYPEGROUP_IDENTIFIER => $contentTypeGroup->identifier |
|
| 204 | ) |
|
| 205 | ) |
|
| 206 | ); |
|
| 207 | break; |
|
| 208 | default: |
|
| 209 | throw new \Exception("Executor 'content_type_group' doesn't support mode '$mode'"); |
|
| 210 | } |
|
| 211 | ||
| 212 | $data[] = $contentTypeGroupData; |
|
| 213 | } |
|
| 214 | ||
| 215 | $this->loginUser($previousUserId); |
|
| 216 | return $data; |
|
| 217 | } |
|
| 218 | ||
| 219 | /** |
|
| 220 | * @param int|string $date if integer, we assume a timestamp |
|
| @@ 167-222 (lines=56) @@ | ||
| 164 | * @throws \Exception |
|
| 165 | * @return array |
|
| 166 | */ |
|
| 167 | public function generateMigration(array $matchCondition, $mode, array $context = array()) |
|
| 168 | { |
|
| 169 | $previousUserId = $this->loginUser($this->getAdminUserIdentifierFromContext($context)); |
|
| 170 | $sectionCollection = $this->sectionMatcher->match($matchCondition); |
|
| 171 | $data = array(); |
|
| 172 | ||
| 173 | /** @var \eZ\Publish\API\Repository\Values\Content\Section $section */ |
|
| 174 | foreach ($sectionCollection as $section) { |
|
| 175 | ||
| 176 | $sectionData = array( |
|
| 177 | 'type' => reset($this->supportedStepTypes), |
|
| 178 | 'mode' => $mode, |
|
| 179 | ); |
|
| 180 | ||
| 181 | switch ($mode) { |
|
| 182 | case 'create': |
|
| 183 | $sectionData = array_merge( |
|
| 184 | $sectionData, |
|
| 185 | array( |
|
| 186 | 'identifier' => $section->identifier, |
|
| 187 | 'name' => $section->name, |
|
| 188 | ) |
|
| 189 | ); |
|
| 190 | break; |
|
| 191 | case 'update': |
|
| 192 | $sectionData = array_merge( |
|
| 193 | $sectionData, |
|
| 194 | array( |
|
| 195 | 'match' => array( |
|
| 196 | SectionMatcher::MATCH_SECTION_ID => $section->id |
|
| 197 | ), |
|
| 198 | 'identifier' => $section->identifier, |
|
| 199 | 'name' => $section->name, |
|
| 200 | ) |
|
| 201 | ); |
|
| 202 | break; |
|
| 203 | case 'delete': |
|
| 204 | $sectionData = array_merge( |
|
| 205 | $sectionData, |
|
| 206 | array( |
|
| 207 | 'match' => array( |
|
| 208 | SectionMatcher::MATCH_SECTION_ID => $section->id |
|
| 209 | ) |
|
| 210 | ) |
|
| 211 | ); |
|
| 212 | break; |
|
| 213 | default: |
|
| 214 | throw new \Exception("Executor 'section' doesn't support mode '$mode'"); |
|
| 215 | } |
|
| 216 | ||
| 217 | $data[] = $sectionData; |
|
| 218 | } |
|
| 219 | ||
| 220 | $this->loginUser($previousUserId); |
|
| 221 | return $data; |
|
| 222 | } |
|
| 223 | } |
|
| 224 | ||