Code Duplication    Length = 25-25 lines in 2 locations

eZ/Publish/Core/Repository/ContentService.php 2 locations

@@ 2139-2163 (lines=25) @@
2136
     *
2137
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
2138
     */
2139
    public function hideContent(ContentInfo $contentInfo): void
2140
    {
2141
        if (!$this->repository->canUser('content', 'hide', $contentInfo)) {
2142
            throw new UnauthorizedException('content', 'hide', ['contentId' => $contentInfo->id]);
2143
        }
2144
2145
        $this->repository->beginTransaction();
2146
        try {
2147
            $this->persistenceHandler->contentHandler()->updateMetadata(
2148
                $contentInfo->id,
2149
                new SPIMetadataUpdateStruct([
2150
                    'isHidden' => true,
2151
                ])
2152
            );
2153
            $locationHandler = $this->persistenceHandler->locationHandler();
2154
            $childLocations = $locationHandler->loadLocationsByContent($contentInfo->id);
2155
            foreach ($childLocations as $childLocation) {
2156
                $locationHandler->setInvisible($childLocation->id);
2157
            }
2158
            $this->repository->commit();
2159
        } catch (Exception $e) {
2160
            $this->repository->rollback();
2161
            throw $e;
2162
        }
2163
    }
2164
2165
    /**
2166
     * Reveals Content hidden by hideContent API.
@@ 2173-2197 (lines=25) @@
2170
     *
2171
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
2172
     */
2173
    public function revealContent(ContentInfo $contentInfo): void
2174
    {
2175
        if (!$this->repository->canUser('content', 'hide', $contentInfo)) {
2176
            throw new UnauthorizedException('content', 'hide', ['contentId' => $contentInfo->id]);
2177
        }
2178
2179
        $this->repository->beginTransaction();
2180
        try {
2181
            $this->persistenceHandler->contentHandler()->updateMetadata(
2182
                $contentInfo->id,
2183
                new SPIMetadataUpdateStruct([
2184
                    'isHidden' => false,
2185
                ])
2186
            );
2187
            $locationHandler = $this->persistenceHandler->locationHandler();
2188
            $childLocations = $locationHandler->loadLocationsByContent($contentInfo->id);
2189
            foreach ($childLocations as $childLocation) {
2190
                $locationHandler->setVisible($childLocation->id);
2191
            }
2192
            $this->repository->commit();
2193
        } catch (Exception $e) {
2194
            $this->repository->rollback();
2195
            throw $e;
2196
        }
2197
    }
2198
2199
    /**
2200
     * Instantiates a new content create struct object.