Global navigation

   Documentation Center
   eZ Studio & eZ Platform
     User Manual
     Technical Manual
   eZ Publish 4.x / legacy

eZ Publish (5.x)

eZ Publish 5.x | For eZ Platform & eZ Studio topics see Technical manual and User manual, for eZ Publish 4.x and Legacy topics see eZ Publish legacy

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


Code Block
titlehide/unhide location
        // 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
             // load the location info from the given location id
            $location = $contentService->loadContentInfo($contentId);
            // hide the location
            $hiddenLocation = $locationService->hideLocation($location);
            // print out the location
            // unhide the location
            $unhiddenLocation = $locationService->unhideLocation($hiddenLocation);
            // print out the location
        catch(\eZ\Publish\API\Repository\Exceptions\NotFoundException $e)
            // react on location not found
        catch(\eZ\Publish\API\Repository\Exceptions\UnauthorizedException $e)
            // react on permission denied

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)