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