| @@ 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 |
|
| @@ 179-234 (lines=56) @@ | ||
| 176 | * @throws \Exception |
|
| 177 | * @return array |
|
| 178 | */ |
|
| 179 | public function generateMigration(array $matchCondition, $mode, array $context = array()) |
|
| 180 | { |
|
| 181 | $previousUserId = $this->loginUser($this->getAdminUserIdentifierFromContext($context)); |
|
| 182 | $sectionCollection = $this->sectionMatcher->match($matchCondition); |
|
| 183 | $data = array(); |
|
| 184 | ||
| 185 | /** @var \eZ\Publish\API\Repository\Values\Content\Section $section */ |
|
| 186 | foreach ($sectionCollection as $section) { |
|
| 187 | ||
| 188 | $sectionData = array( |
|
| 189 | 'type' => reset($this->supportedStepTypes), |
|
| 190 | 'mode' => $mode, |
|
| 191 | ); |
|
| 192 | ||
| 193 | switch ($mode) { |
|
| 194 | case 'create': |
|
| 195 | $sectionData = array_merge( |
|
| 196 | $sectionData, |
|
| 197 | array( |
|
| 198 | 'identifier' => $section->identifier, |
|
| 199 | 'name' => $section->name, |
|
| 200 | ) |
|
| 201 | ); |
|
| 202 | break; |
|
| 203 | case 'update': |
|
| 204 | $sectionData = array_merge( |
|
| 205 | $sectionData, |
|
| 206 | array( |
|
| 207 | 'match' => array( |
|
| 208 | SectionMatcher::MATCH_SECTION_ID => $section->id |
|
| 209 | ), |
|
| 210 | 'identifier' => $section->identifier, |
|
| 211 | 'name' => $section->name, |
|
| 212 | ) |
|
| 213 | ); |
|
| 214 | break; |
|
| 215 | case 'delete': |
|
| 216 | $sectionData = array_merge( |
|
| 217 | $sectionData, |
|
| 218 | array( |
|
| 219 | 'match' => array( |
|
| 220 | SectionMatcher::MATCH_SECTION_ID => $section->id |
|
| 221 | ) |
|
| 222 | ) |
|
| 223 | ); |
|
| 224 | break; |
|
| 225 | default: |
|
| 226 | throw new \Exception("Executor 'section' doesn't support mode '$mode'"); |
|
| 227 | } |
|
| 228 | ||
| 229 | $data[] = $sectionData; |
|
| 230 | } |
|
| 231 | ||
| 232 | $this->loginUser($previousUserId); |
|
| 233 | return $data; |
|
| 234 | } |
|
| 235 | } |
|
| 236 | ||