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