|
@@ 335-351 (lines=17) @@
|
| 332 |
|
* |
| 333 |
|
* @return \eZ\Publish\API\Repository\Values\Content\Content |
| 334 |
|
*/ |
| 335 |
|
public function loadContent($contentId, array $languages = null, $versionNo = null, $useAlwaysAvailable = true) |
| 336 |
|
{ |
| 337 |
|
$content = $this->internalLoadContent($contentId, $languages, $versionNo, false, $useAlwaysAvailable); |
| 338 |
|
|
| 339 |
|
if (!$this->repository->canUser('content', 'read', $content)) { |
| 340 |
|
throw new UnauthorizedException('content', 'read', array('contentId' => $contentId)); |
| 341 |
|
} |
| 342 |
|
|
| 343 |
|
if ( |
| 344 |
|
$content->getVersionInfo()->status !== APIVersionInfo::STATUS_PUBLISHED |
| 345 |
|
&& !$this->repository->canUser('content', 'versionread', $content) |
| 346 |
|
) { |
| 347 |
|
throw new UnauthorizedException('content', 'versionread', array('contentId' => $contentId, 'versionNo' => $versionNo)); |
| 348 |
|
} |
| 349 |
|
|
| 350 |
|
return $content; |
| 351 |
|
} |
| 352 |
|
|
| 353 |
|
/** |
| 354 |
|
* Loads content in a version of the given content object. |
|
@@ 440-456 (lines=17) @@
|
| 437 |
|
* |
| 438 |
|
* @return \eZ\Publish\API\Repository\Values\Content\Content |
| 439 |
|
*/ |
| 440 |
|
public function loadContentByRemoteId($remoteId, array $languages = null, $versionNo = null, $useAlwaysAvailable = true) |
| 441 |
|
{ |
| 442 |
|
$content = $this->internalLoadContent($remoteId, $languages, $versionNo, true, $useAlwaysAvailable); |
| 443 |
|
|
| 444 |
|
if (!$this->repository->canUser('content', 'read', $content)) { |
| 445 |
|
throw new UnauthorizedException('content', 'read', array('remoteId' => $remoteId)); |
| 446 |
|
} |
| 447 |
|
|
| 448 |
|
if ( |
| 449 |
|
$content->getVersionInfo()->status !== APIVersionInfo::STATUS_PUBLISHED |
| 450 |
|
&& !$this->repository->canUser('content', 'versionread', $content) |
| 451 |
|
) { |
| 452 |
|
throw new UnauthorizedException('content', 'versionread', array('remoteId' => $remoteId, 'versionNo' => $versionNo)); |
| 453 |
|
} |
| 454 |
|
|
| 455 |
|
return $content; |
| 456 |
|
} |
| 457 |
|
|
| 458 |
|
/** |
| 459 |
|
* Creates a new content draft assigned to the authenticated user. |