| @@ 127-149 (lines=23) @@ | ||
| 124 | * |
|
| 125 | * @return \eZ\Publish\SPI\Persistence\Content\VersionInfo[] |
|
| 126 | */ |
|
| 127 | public function listVersions($contentId, $status = null, $limit = -1) |
|
| 128 | { |
|
| 129 | $rows = $this->contentGateway->listVersions($contentId, $status, $limit); |
|
| 130 | if (empty($rows)) { |
|
| 131 | return []; |
|
| 132 | } |
|
| 133 | ||
| 134 | $idVersionPairs = array_map( |
|
| 135 | function ($row) use ($contentId) { |
|
| 136 | return [ |
|
| 137 | 'id' => $contentId, |
|
| 138 | 'version' => $row['ezcontentobject_version_version'], |
|
| 139 | ]; |
|
| 140 | }, |
|
| 141 | $rows |
|
| 142 | ); |
|
| 143 | $nameRows = $this->contentGateway->loadVersionedNameData($idVersionPairs); |
|
| 144 | ||
| 145 | return $this->contentMapper->extractVersionInfoListFromRows( |
|
| 146 | $rows, |
|
| 147 | $nameRows |
|
| 148 | ); |
|
| 149 | } |
|
| 150 | ||
| 151 | /** |
|
| 152 | * Loads the data for the location identified by $locationId. |
|
| @@ 490-509 (lines=20) @@ | ||
| 487 | * |
|
| 488 | * @return \eZ\Publish\SPI\Persistence\Content\VersionInfo[] |
|
| 489 | */ |
|
| 490 | public function loadDraftsForUser($userId) |
|
| 491 | { |
|
| 492 | $rows = $this->contentGateway->listVersionsForUser($userId, VersionInfo::STATUS_DRAFT); |
|
| 493 | if (empty($rows)) { |
|
| 494 | return []; |
|
| 495 | } |
|
| 496 | ||
| 497 | $idVersionPairs = array_map( |
|
| 498 | function ($row) { |
|
| 499 | return [ |
|
| 500 | 'id' => $row['ezcontentobject_version_contentobject_id'], |
|
| 501 | 'version' => $row['ezcontentobject_version_version'], |
|
| 502 | ]; |
|
| 503 | }, |
|
| 504 | $rows |
|
| 505 | ); |
|
| 506 | $nameRows = $this->contentGateway->loadVersionedNameData($idVersionPairs); |
|
| 507 | ||
| 508 | return $this->mapper->extractVersionInfoListFromRows($rows, $nameRows); |
|
| 509 | } |
|
| 510 | ||
| 511 | /** |
|
| 512 | * {@inheritdoc} |
|
| @@ 514-533 (lines=20) @@ | ||
| 511 | /** |
|
| 512 | * {@inheritdoc} |
|
| 513 | */ |
|
| 514 | public function loadDraftListForUser(int $userId, int $offset = 0, int $limit = -1): array |
|
| 515 | { |
|
| 516 | $rows = $this->contentGateway->loadVersionsForUser($userId, VersionInfo::STATUS_DRAFT, $offset, $limit); |
|
| 517 | if (empty($rows)) { |
|
| 518 | return []; |
|
| 519 | } |
|
| 520 | ||
| 521 | $idVersionPairs = array_map( |
|
| 522 | function ($row) { |
|
| 523 | return [ |
|
| 524 | 'id' => $row['ezcontentobject_version_contentobject_id'], |
|
| 525 | 'version' => $row['ezcontentobject_version_version'], |
|
| 526 | ]; |
|
| 527 | }, |
|
| 528 | $rows |
|
| 529 | ); |
|
| 530 | $nameRows = $this->contentGateway->loadVersionedNameData($idVersionPairs); |
|
| 531 | ||
| 532 | return $this->mapper->extractVersionInfoListFromRows($rows, $nameRows); |
|
| 533 | } |
|
| 534 | ||
| 535 | /** |
|
| 536 | * Sets the status of object identified by $contentId and $version to $status. |
|