public function restoreTrashItem($trashItemId, Request $request)
    {
        $requestDestination = null;
        try {
            $requestDestination = $request->headers->get('Destination');
        } catch (InvalidArgumentException $e) {
            // No Destination header
        }

        $parentLocation = null;
        if ($request->headers->has('Destination')) {
            $locationPathParts = explode(
                '/',
                $this->requestParser->parseHref($request->headers->get('Destination'), 'locationPath')
            );

            try {
                $parentLocation = $this->locationService->loadLocation(array_pop($locationPathParts));
            } catch (NotFoundException $e) {
                throw new ForbiddenException($e->getMessage());
            }
        }

        $trashItem = $this->trashService->loadTrashItem($trashItemId);

        if ($requestDestination === null) {
            // If we're recovering under the original location
            // check if it exists, to return "403 Forbidden" in case it does not
            try {
                $this->locationService->loadLocation($trashItem->parentLocationId);
            } catch (NotFoundException $e) {
                throw new ForbiddenException($e->getMessage());
            }
        }

        $location = $this->trashService->recover($trashItem, $parentLocation);

        return new Values\ResourceCreated(
            $this->router->generate(
                'ezpublish_rest_loadLocation',
                array(
                    'locationPath' => trim($location->pathString, '/'),
                )
            )
        );
    }
public function restoreTrashItem($trashItemId, Request $request)
    {
        $requestDestination = null;
        try {
            $requestDestination = $request->headers->get('Destination');
        } catch (InvalidArgumentException $e) {
            // No Destination header
        }

        $parentLocation = null;
        if ($request->headers->has('Destination')) {
            $locationPathParts = explode(
                '/',
                $this->requestParser->parseHref($request->headers->get('Destination'), 'locationPath')
            );

            try {
                $parentLocation = $this->locationService->loadLocation(array_pop($locationPathParts));
            } catch (NotFoundException $e) {
                throw new ForbiddenException($e->getMessage());
            }
        }

        $trashItem = $this->trashService->loadTrashItem($trashItemId);

        if ($requestDestination === null) {
            // If we're recovering under the original location
            // check if it exists, to return "403 Forbidden" in case it does not
            try {
                $this->locationService->loadLocation($trashItem->parentLocationId);
            } catch (NotFoundException $e) {
                throw new ForbiddenException($e->getMessage());
            }
        }

        $location = $this->trashService->recover($trashItem, $parentLocation);

        return new Values\ResourceCreated(
            $this->router->generate(
                'ezpublish_rest_loadLocation',
                array(
                    'locationPath' => trim($location->pathString, '/'),
                )
            )
        );
    }
public function restoreTrashItem ( $ trashItemId , Request $ request ) { $ requestDestination = null ; try { $ requestDestination = $ request -> headers -> get ( 'Destination' ) ; } catch ( InvalidArgumentException $ e ) { // No Destination header } $ parentLocation = null ; if ( $ request -> headers -> has ( 'Destination' ) ) { $ locationPathParts = explode ( '/' , $ this -> requestParser -> parseHref ( $ request -> headers -> get ( 'Destination' ) , 'locationPath' ) ) ; try { $ parentLocation = $ this -> locationService -> loadLocation ( array_pop ( $ locationPathParts ) ) ; } catch ( NotFoundException $ e ) { throw new ForbiddenException ( $ e -> getMessage ( ) ) ; } } $ trashItem = $ this -> trashService -> loadTrashItem ( $ trashItemId ) ; if ( $ requestDestination === null ) { // If we're recovering under the original location // check if it exists, to return "403 Forbidden" in case it does not try { $ this -> locationService -> loadLocation ( $ trashItem -> parentLocationId ) ; } catch ( NotFoundException $ e ) { throw new ForbiddenException ( $ e -> getMessage ( ) ) ; } } $ location = $ this -> trashService -> recover ( $ trashItem , $ parentLocation ) ; return new Values \ ResourceCreated ( $ this -> router -> generate ( 'ezpublish_rest_loadLocation' , array ( 'locationPath' => trim ( $ location -> pathString , '/' ) , ) ) ) ; }
Restores a trashItem.

@param $trashItemId

@throws \eZ\Publish\Core\REST\Server\Exceptions\ForbiddenException

@return \eZ\Publish\Core\REST\Server\Values\ResourceCreated
Restores a trashItem .