|
@@ 2255-2279 (lines=25) @@
|
| 2252 |
|
* |
| 2253 |
|
* @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
| 2254 |
|
*/ |
| 2255 |
|
public function hideContent(ContentInfo $contentInfo): void |
| 2256 |
|
{ |
| 2257 |
|
if (!$this->repository->canUser('content', 'hide', $contentInfo)) { |
| 2258 |
|
throw new UnauthorizedException('content', 'hide', ['contentId' => $contentInfo->id]); |
| 2259 |
|
} |
| 2260 |
|
|
| 2261 |
|
$this->repository->beginTransaction(); |
| 2262 |
|
try { |
| 2263 |
|
$this->persistenceHandler->contentHandler()->updateMetadata( |
| 2264 |
|
$contentInfo->id, |
| 2265 |
|
new SPIMetadataUpdateStruct([ |
| 2266 |
|
'isHidden' => true, |
| 2267 |
|
]) |
| 2268 |
|
); |
| 2269 |
|
$locationHandler = $this->persistenceHandler->locationHandler(); |
| 2270 |
|
$childLocations = $locationHandler->loadLocationsByContent($contentInfo->id); |
| 2271 |
|
foreach ($childLocations as $childLocation) { |
| 2272 |
|
$locationHandler->setInvisible($childLocation->id); |
| 2273 |
|
} |
| 2274 |
|
$this->repository->commit(); |
| 2275 |
|
} catch (Exception $e) { |
| 2276 |
|
$this->repository->rollback(); |
| 2277 |
|
throw $e; |
| 2278 |
|
} |
| 2279 |
|
} |
| 2280 |
|
|
| 2281 |
|
/** |
| 2282 |
|
* Reveals Content hidden by hideContent API. |
|
@@ 2289-2313 (lines=25) @@
|
| 2286 |
|
* |
| 2287 |
|
* @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
| 2288 |
|
*/ |
| 2289 |
|
public function revealContent(ContentInfo $contentInfo): void |
| 2290 |
|
{ |
| 2291 |
|
if (!$this->repository->canUser('content', 'hide', $contentInfo)) { |
| 2292 |
|
throw new UnauthorizedException('content', 'hide', ['contentId' => $contentInfo->id]); |
| 2293 |
|
} |
| 2294 |
|
|
| 2295 |
|
$this->repository->beginTransaction(); |
| 2296 |
|
try { |
| 2297 |
|
$this->persistenceHandler->contentHandler()->updateMetadata( |
| 2298 |
|
$contentInfo->id, |
| 2299 |
|
new SPIMetadataUpdateStruct([ |
| 2300 |
|
'isHidden' => false, |
| 2301 |
|
]) |
| 2302 |
|
); |
| 2303 |
|
$locationHandler = $this->persistenceHandler->locationHandler(); |
| 2304 |
|
$childLocations = $locationHandler->loadLocationsByContent($contentInfo->id); |
| 2305 |
|
foreach ($childLocations as $childLocation) { |
| 2306 |
|
$locationHandler->setVisible($childLocation->id); |
| 2307 |
|
} |
| 2308 |
|
$this->repository->commit(); |
| 2309 |
|
} catch (Exception $e) { |
| 2310 |
|
$this->repository->rollback(); |
| 2311 |
|
throw $e; |
| 2312 |
|
} |
| 2313 |
|
} |
| 2314 |
|
|
| 2315 |
|
/** |
| 2316 |
|
* Instantiates a new content create struct object. |