| @@ 286-311 (lines=26) @@ | ||
| 283 | * |
|
| 284 | * @param \eZ\Publish\API\Repository\Values\ContentType\ContentTypeGroup $contentTypeGroup |
|
| 285 | */ |
|
| 286 | public function deleteContentTypeGroup(APIContentTypeGroup $contentTypeGroup) |
|
| 287 | { |
|
| 288 | if (!$this->repository->canUser('class', 'delete', $contentTypeGroup)) { |
|
| 289 | throw new UnauthorizedException('ContentType', 'delete'); |
|
| 290 | } |
|
| 291 | ||
| 292 | $loadedContentTypeGroup = $this->loadContentTypeGroup($contentTypeGroup->id); |
|
| 293 | ||
| 294 | $this->repository->beginTransaction(); |
|
| 295 | try { |
|
| 296 | $this->contentTypeHandler->deleteGroup( |
|
| 297 | $loadedContentTypeGroup->id |
|
| 298 | ); |
|
| 299 | $this->repository->commit(); |
|
| 300 | } catch (APIBadStateException $e) { |
|
| 301 | $this->repository->rollback(); |
|
| 302 | throw new InvalidArgumentException( |
|
| 303 | '$contentTypeGroup', |
|
| 304 | 'Content type group has content type instances', |
|
| 305 | $e |
|
| 306 | ); |
|
| 307 | } catch (Exception $e) { |
|
| 308 | $this->repository->rollback(); |
|
| 309 | throw $e; |
|
| 310 | } |
|
| 311 | } |
|
| 312 | ||
| 313 | /** |
|
| 314 | * Validates input ContentType create struct. |
|
| @@ 493-525 (lines=33) @@ | ||
| 490 | * |
|
| 491 | * @param \eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft |
|
| 492 | */ |
|
| 493 | public function publishRoleDraft(APIRoleDraft $roleDraft) |
|
| 494 | { |
|
| 495 | if ($this->repository->hasAccess('role', 'update') !== true) { |
|
| 496 | throw new UnauthorizedException('role', 'update'); |
|
| 497 | } |
|
| 498 | ||
| 499 | try { |
|
| 500 | $loadedRoleDraft = $this->loadRoleDraft($roleDraft->id); |
|
| 501 | } catch (APINotFoundException $e) { |
|
| 502 | throw new BadStateException( |
|
| 503 | '$roleDraft', |
|
| 504 | 'The role does not have a draft.', |
|
| 505 | $e |
|
| 506 | ); |
|
| 507 | } |
|
| 508 | ||
| 509 | // TODO: Uncomment when role policy editing is done, see EZP-24711 & EZP-24713 |
|
| 510 | /*if (count($loadedRoleDraft->getPolicies()) === 0) { |
|
| 511 | throw new InvalidArgumentException( |
|
| 512 | "\$roleDraft", |
|
| 513 | 'The role draft should have at least one policy.' |
|
| 514 | ); |
|
| 515 | }*/ |
|
| 516 | ||
| 517 | $this->repository->beginTransaction(); |
|
| 518 | try { |
|
| 519 | $this->userHandler->publishRoleDraft($loadedRoleDraft->id); |
|
| 520 | $this->repository->commit(); |
|
| 521 | } catch (Exception $e) { |
|
| 522 | $this->repository->rollback(); |
|
| 523 | throw $e; |
|
| 524 | } |
|
| 525 | } |
|
| 526 | ||
| 527 | /** |
|
| 528 | * Updates the name of the role. |
|
| @@ 335-354 (lines=20) @@ | ||
| 332 | * |
|
| 333 | * @param \eZ\Publish\API\Repository\Values\Content\Language $language |
|
| 334 | */ |
|
| 335 | public function deleteLanguage(Language $language) |
|
| 336 | { |
|
| 337 | if (!$this->repository->canUser('content', 'translations', $language)) { |
|
| 338 | throw new UnauthorizedException('content', 'translations'); |
|
| 339 | } |
|
| 340 | ||
| 341 | $loadedLanguage = $this->loadLanguageById($language->id); |
|
| 342 | ||
| 343 | $this->repository->beginTransaction(); |
|
| 344 | try { |
|
| 345 | $this->languageHandler->delete($loadedLanguage->id); |
|
| 346 | $this->repository->commit(); |
|
| 347 | } catch (LogicException $e) { |
|
| 348 | $this->repository->rollback(); |
|
| 349 | throw new InvalidArgumentException('language', $e->getMessage(), $e); |
|
| 350 | } catch (Exception $e) { |
|
| 351 | $this->repository->rollback(); |
|
| 352 | throw $e; |
|
| 353 | } |
|
| 354 | } |
|
| 355 | ||
| 356 | /** |
|
| 357 | * Returns a configured default language code. |
|