| @@ 82-115 (lines=34) @@ | ||
| 79 | * |
|
| 80 | * @return \eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroup |
|
| 81 | */ |
|
| 82 | public function createObjectStateGroup(ObjectStateGroupCreateStruct $objectStateGroupCreateStruct) |
|
| 83 | { |
|
| 84 | if ($this->repository->hasAccess('state', 'administrate') !== true) { |
|
| 85 | throw new UnauthorizedException('state', 'administrate'); |
|
| 86 | } |
|
| 87 | ||
| 88 | $inputStruct = $this->buildCreateInputStruct( |
|
| 89 | $objectStateGroupCreateStruct->identifier, |
|
| 90 | $objectStateGroupCreateStruct->defaultLanguageCode, |
|
| 91 | $objectStateGroupCreateStruct->names, |
|
| 92 | $objectStateGroupCreateStruct->descriptions |
|
| 93 | ); |
|
| 94 | ||
| 95 | try { |
|
| 96 | $this->objectStateHandler->loadGroupByIdentifier($inputStruct->identifier); |
|
| 97 | throw new InvalidArgumentException( |
|
| 98 | 'objectStateGroupCreateStruct', |
|
| 99 | 'Object state group with provided identifier already exists' |
|
| 100 | ); |
|
| 101 | } catch (APINotFoundException $e) { |
|
| 102 | // Do nothing |
|
| 103 | } |
|
| 104 | ||
| 105 | $this->repository->beginTransaction(); |
|
| 106 | try { |
|
| 107 | $spiObjectStateGroup = $this->objectStateHandler->createGroup($inputStruct); |
|
| 108 | $this->repository->commit(); |
|
| 109 | } catch (Exception $e) { |
|
| 110 | $this->repository->rollback(); |
|
| 111 | throw $e; |
|
| 112 | } |
|
| 113 | ||
| 114 | return $this->buildDomainObjectStateGroupObject($spiObjectStateGroup); |
|
| 115 | } |
|
| 116 | ||
| 117 | /** |
|
| 118 | * {@inheritdoc} |
|
| @@ 84-106 (lines=23) @@ | ||
| 81 | /** |
|
| 82 | * {@inheritdoc} |
|
| 83 | */ |
|
| 84 | public function updateUrl(URL $url, URLUpdateStruct $struct) |
|
| 85 | { |
|
| 86 | if ($this->repository->hasAccess('url', 'update') !== true) { |
|
| 87 | throw new UnauthorizedException('url', 'update'); |
|
| 88 | } |
|
| 89 | ||
| 90 | if (!$this->isUnique($url->id, $struct->url)) { |
|
| 91 | throw new InvalidArgumentException('struct', 'url already exists'); |
|
| 92 | } |
|
| 93 | ||
| 94 | $updateStruct = $this->buildUpdateStruct($this->loadById($url->id), $struct); |
|
| 95 | ||
| 96 | $this->repository->beginTransaction(); |
|
| 97 | try { |
|
| 98 | $this->urlHandler->updateUrl($url->id, $updateStruct); |
|
| 99 | $this->repository->commit(); |
|
| 100 | } catch (\Exception $e) { |
|
| 101 | $this->repository->rollback(); |
|
| 102 | throw $e; |
|
| 103 | } |
|
| 104 | ||
| 105 | return $this->loadById($url->id); |
|
| 106 | } |
|
| 107 | ||
| 108 | /** |
|
| 109 | * {@inheritdoc} |
|