| @@ 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. |
|
| @@ 334-353 (lines=20) @@ | ||
| 331 | * |
|
| 332 | * @param \eZ\Publish\API\Repository\Values\Content\Language $language |
|
| 333 | */ |
|
| 334 | public function deleteLanguage(Language $language) |
|
| 335 | { |
|
| 336 | if (!$this->repository->canUser('content', 'translations', $language)) { |
|
| 337 | throw new UnauthorizedException('content', 'translations'); |
|
| 338 | } |
|
| 339 | ||
| 340 | $loadedLanguage = $this->loadLanguageById($language->id); |
|
| 341 | ||
| 342 | $this->repository->beginTransaction(); |
|
| 343 | try { |
|
| 344 | $this->languageHandler->delete($loadedLanguage->id); |
|
| 345 | $this->repository->commit(); |
|
| 346 | } catch (LogicException $e) { |
|
| 347 | $this->repository->rollback(); |
|
| 348 | throw new InvalidArgumentException('language', $e->getMessage(), $e); |
|
| 349 | } catch (Exception $e) { |
|
| 350 | $this->repository->rollback(); |
|
| 351 | throw $e; |
|
| 352 | } |
|
| 353 | } |
|
| 354 | ||
| 355 | /** |
|
| 356 | * Returns a configured default language code. |
|
| @@ 492-524 (lines=33) @@ | ||
| 489 | * |
|
| 490 | * @param \eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft |
|
| 491 | */ |
|
| 492 | public function publishRoleDraft(APIRoleDraft $roleDraft) |
|
| 493 | { |
|
| 494 | if ($this->repository->hasAccess('role', 'update') !== true) { |
|
| 495 | throw new UnauthorizedException('role', 'update'); |
|
| 496 | } |
|
| 497 | ||
| 498 | try { |
|
| 499 | $loadedRoleDraft = $this->loadRoleDraft($roleDraft->id); |
|
| 500 | } catch (APINotFoundException $e) { |
|
| 501 | throw new BadStateException( |
|
| 502 | '$roleDraft', |
|
| 503 | 'The role does not have a draft.', |
|
| 504 | $e |
|
| 505 | ); |
|
| 506 | } |
|
| 507 | ||
| 508 | $this->repository->beginTransaction(); |
|
| 509 | try { |
|
| 510 | $this->userHandler->publishRoleDraft($loadedRoleDraft->id); |
|
| 511 | $this->repository->commit(); |
|
| 512 | } catch (Exception $e) { |
|
| 513 | $this->repository->rollback(); |
|
| 514 | throw $e; |
|
| 515 | } |
|
| 516 | } |
|
| 517 | ||
| 518 | /** |
|
| 519 | * Updates the name of the role. |
|
| 520 | * |
|
| 521 | * @deprecated since 6.0, use {@see updateRoleDraft} |
|
| 522 | * |
|
| 523 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to update a role |
|
| 524 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the name of the role already exists |
|
| 525 | * |
|
| 526 | * @param \eZ\Publish\API\Repository\Values\User\Role $role |
|
| 527 | * @param \eZ\Publish\API\Repository\Values\User\RoleUpdateStruct $roleUpdateStruct |
|