| @@ 232-247 (lines=16) @@ | ||
| 229 | * |
|
| 230 | * @return \eZ\Publish\API\Repository\Values\Content\Section |
|
| 231 | */ |
|
| 232 | public function loadSectionByIdentifier($sectionIdentifier) |
|
| 233 | { |
|
| 234 | if (!is_string($sectionIdentifier) || empty($sectionIdentifier)) { |
|
| 235 | throw new InvalidArgumentValue('sectionIdentifier', $sectionIdentifier); |
|
| 236 | } |
|
| 237 | ||
| 238 | $section = $this->buildDomainSectionObject( |
|
| 239 | $this->sectionHandler->loadByIdentifier($sectionIdentifier) |
|
| 240 | ); |
|
| 241 | ||
| 242 | if (!$this->permissionResolver->canUser('section', 'view', $section)) { |
|
| 243 | throw new UnauthorizedException('section', 'view'); |
|
| 244 | } |
|
| 245 | ||
| 246 | return $section; |
|
| 247 | } |
|
| 248 | ||
| 249 | /** |
|
| 250 | * Counts the contents which $section is assigned to. |
|
| @@ 566-581 (lines=16) @@ | ||
| 563 | * |
|
| 564 | * @return \eZ\Publish\API\Repository\Values\User\Role |
|
| 565 | */ |
|
| 566 | public function loadRoleByIdentifier($identifier) |
|
| 567 | { |
|
| 568 | if (!is_string($identifier)) { |
|
| 569 | throw new InvalidArgumentValue('identifier', $identifier); |
|
| 570 | } |
|
| 571 | ||
| 572 | $spiRole = $this->userHandler->loadRoleByIdentifier($identifier); |
|
| 573 | ||
| 574 | $role = $this->roleDomainMapper->buildDomainRoleObject($spiRole); |
|
| 575 | ||
| 576 | if (!$this->permissionResolver->canUser('role', 'read', $role)) { |
|
| 577 | throw new UnauthorizedException('role', 'read'); |
|
| 578 | } |
|
| 579 | ||
| 580 | return $role; |
|
| 581 | } |
|
| 582 | ||
| 583 | /** |
|
| 584 | * Loads all roles, excluding the ones the current user is not allowed to read. |
|