...
Code Block | ||||
---|---|---|---|---|
| ||||
// get the location service from the repository $locationService = $repository->getLocationService(); // get the user service from the repsitory $userService = $repository->getUserService(); // load admin user $user = $userService->loadUser(14); // set current user to admin $repository->setCurrentUser($user); try { // load the location info from the given location id $location = $contentService->loadContentInfo($contentId); // hide the location $hiddenLocation = $locationService->hideLocation($location); // print out the location print_r($hiddenLocation); // unhide the location $unhiddenLocation = $locationService->unhideLocation($hiddenLocation); // print out the location print_r($unhiddenLocation); } catch(\eZ\Publish\API\Repository\Exceptions\NotFoundException $e) { // react on location not found $output->writeln($e->getMessage()); } catch(\eZ\Publish\API\Repository\Exceptions\UnauthorizedException $e) { // react on permission denied $output->writeln($e->getMessage()); } |
Receipt 15 - Deleting locations
If a content has more than one location the method
LocationService::delete(Location $location)
removes the location and if exists all descendants of the location. However the content itself is untouched as it has still other locations.
If the deleted location is the last one of the content the content itself is deleted. This applies also to all descendants of the location.
Alternatively a location can also moved to the trash via the method:
TrashService::trash(Location $location)
Receipt 16 - Deleting Content
The result of deleting content is equivalent to deleting all locations of content (see Receipt 15).
It is done via the method:
ContentService::delete(ContentInfo $contentInfo)