Code Duplication    Length = 20-23 lines in 3 locations

eZ/Publish/Core/Persistence/Legacy/Content/TreeHandler.php 1 location

@@ 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.

eZ/Publish/Core/Persistence/Legacy/Content/Handler.php 2 locations

@@ 476-495 (lines=20) @@
473
     *
474
     * @return \eZ\Publish\SPI\Persistence\Content\VersionInfo[]
475
     */
476
    public function loadDraftsForUser($userId)
477
    {
478
        $rows = $this->contentGateway->listVersionsForUser($userId, VersionInfo::STATUS_DRAFT);
479
        if (empty($rows)) {
480
            return [];
481
        }
482
483
        $idVersionPairs = array_map(
484
            function ($row) {
485
                return [
486
                    'id' => $row['ezcontentobject_version_contentobject_id'],
487
                    'version' => $row['ezcontentobject_version_version'],
488
                ];
489
            },
490
            $rows
491
        );
492
        $nameRows = $this->contentGateway->loadVersionedNameData($idVersionPairs);
493
494
        return $this->mapper->extractVersionInfoListFromRows($rows, $nameRows);
495
    }
496
497
    public function loadDraftListForUser(int $userId, int $offset = 0, int $limit = -1): array
498
    {
@@ 497-516 (lines=20) @@
494
        return $this->mapper->extractVersionInfoListFromRows($rows, $nameRows);
495
    }
496
497
    public function loadDraftListForUser(int $userId, int $offset = 0, int $limit = -1): array
498
    {
499
        $rows = $this->contentGateway->loadVersionsForUser($userId, VersionInfo::STATUS_DRAFT, $offset, $limit);
500
        if (empty($rows)) {
501
            return [];
502
        }
503
504
        $idVersionPairs = array_map(
505
            static function (array $row): array {
506
                return [
507
                    'id' => $row['ezcontentobject_version_contentobject_id'],
508
                    'version' => $row['ezcontentobject_version_version'],
509
                ];
510
            },
511
            $rows
512
        );
513
        $nameRows = $this->contentGateway->loadVersionedNameData($idVersionPairs);
514
515
        return $this->mapper->extractVersionInfoListFromRows($rows, $nameRows);
516
    }
517
518
    /**
519
     * Sets the status of object identified by $contentId and $version to $status.