|
@@ 2191-2215 (lines=25) @@
|
| 2188 |
|
* |
| 2189 |
|
* @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
| 2190 |
|
*/ |
| 2191 |
|
public function hideContent(ContentInfo $contentInfo): void |
| 2192 |
|
{ |
| 2193 |
|
if (!$this->repository->canUser('content', 'hide', $contentInfo)) { |
| 2194 |
|
throw new UnauthorizedException('content', 'hide', ['contentId' => $contentInfo->id]); |
| 2195 |
|
} |
| 2196 |
|
|
| 2197 |
|
$this->repository->beginTransaction(); |
| 2198 |
|
try { |
| 2199 |
|
$this->persistenceHandler->contentHandler()->updateMetadata( |
| 2200 |
|
$contentInfo->id, |
| 2201 |
|
new SPIMetadataUpdateStruct([ |
| 2202 |
|
'isHidden' => true, |
| 2203 |
|
]) |
| 2204 |
|
); |
| 2205 |
|
$locationHandler = $this->persistenceHandler->locationHandler(); |
| 2206 |
|
$childLocations = $locationHandler->loadLocationsByContent($contentInfo->id); |
| 2207 |
|
foreach ($childLocations as $childLocation) { |
| 2208 |
|
$locationHandler->setInvisible($childLocation->id); |
| 2209 |
|
} |
| 2210 |
|
$this->repository->commit(); |
| 2211 |
|
} catch (Exception $e) { |
| 2212 |
|
$this->repository->rollback(); |
| 2213 |
|
throw $e; |
| 2214 |
|
} |
| 2215 |
|
} |
| 2216 |
|
|
| 2217 |
|
/** |
| 2218 |
|
* Reveals Content hidden by hideContent API. |
|
@@ 2225-2249 (lines=25) @@
|
| 2222 |
|
* |
| 2223 |
|
* @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
| 2224 |
|
*/ |
| 2225 |
|
public function revealContent(ContentInfo $contentInfo): void |
| 2226 |
|
{ |
| 2227 |
|
if (!$this->repository->canUser('content', 'hide', $contentInfo)) { |
| 2228 |
|
throw new UnauthorizedException('content', 'hide', ['contentId' => $contentInfo->id]); |
| 2229 |
|
} |
| 2230 |
|
|
| 2231 |
|
$this->repository->beginTransaction(); |
| 2232 |
|
try { |
| 2233 |
|
$this->persistenceHandler->contentHandler()->updateMetadata( |
| 2234 |
|
$contentInfo->id, |
| 2235 |
|
new SPIMetadataUpdateStruct([ |
| 2236 |
|
'isHidden' => false, |
| 2237 |
|
]) |
| 2238 |
|
); |
| 2239 |
|
$locationHandler = $this->persistenceHandler->locationHandler(); |
| 2240 |
|
$childLocations = $locationHandler->loadLocationsByContent($contentInfo->id); |
| 2241 |
|
foreach ($childLocations as $childLocation) { |
| 2242 |
|
$locationHandler->setVisible($childLocation->id); |
| 2243 |
|
} |
| 2244 |
|
$this->repository->commit(); |
| 2245 |
|
} catch (Exception $e) { |
| 2246 |
|
$this->repository->rollback(); |
| 2247 |
|
throw $e; |
| 2248 |
|
} |
| 2249 |
|
} |
| 2250 |
|
|
| 2251 |
|
/** |
| 2252 |
|
* Instantiates a new content create struct object. |