public function setObjectStatesForContent($contentId, Request $request)
    {
        $newObjectStates = $this->inputDispatcher->parse(
            new Message(
                array('Content-Type' => $request->headers->get('Content-Type')),
                $request->getContent()
            )
        );

        $countByGroups = array();
        foreach ($newObjectStates as $newObjectState) {
            $groupId = (int)$newObjectState->groupId;
            if (array_key_exists($groupId, $countByGroups)) {
                ++$countByGroups[$groupId];
            } else {
                $countByGroups[$groupId] = 1;
            }
        }

        foreach ($countByGroups as $groupId => $count) {
            if ($count > 1) {
                throw new ForbiddenException("Multiple object states provided for group with ID $groupId");
            }
        }

        $contentInfo = $this->contentService->loadContentInfo($contentId);

        $contentObjectStates = array();
        foreach ($newObjectStates as $newObjectState) {
            $objectStateGroup = $this->objectStateService->loadObjectStateGroup($newObjectState->groupId);
            $this->objectStateService->setContentState($contentInfo, $objectStateGroup, $newObjectState->objectState);
            $contentObjectStates[(int)$objectStateGroup->id] = $newObjectState;
        }

        return new ContentObjectStates($contentObjectStates);
    }
public function setObjectStatesForContent($contentId, Request $request)
    {
        $newObjectStates = $this->inputDispatcher->parse(
            new Message(
                array('Content-Type' => $request->headers->get('Content-Type')),
                $request->getContent()
            )
        );

        $countByGroups = array();
        foreach ($newObjectStates as $newObjectState) {
            $groupId = (int)$newObjectState->groupId;
            if (array_key_exists($groupId, $countByGroups)) {
                ++$countByGroups[$groupId];
            } else {
                $countByGroups[$groupId] = 1;
            }
        }

        foreach ($countByGroups as $groupId => $count) {
            if ($count > 1) {
                throw new ForbiddenException("Multiple object states provided for group with ID $groupId");
            }
        }

        $contentInfo = $this->contentService->loadContentInfo($contentId);

        $contentObjectStates = array();
        foreach ($newObjectStates as $newObjectState) {
            $objectStateGroup = $this->objectStateService->loadObjectStateGroup($newObjectState->groupId);
            $this->objectStateService->setContentState($contentInfo, $objectStateGroup, $newObjectState->objectState);
            $contentObjectStates[(int)$objectStateGroup->id] = $newObjectState;
        }

        return new ContentObjectStates($contentObjectStates);
    }
public function setObjectStatesForContent ( $ contentId , Request $ request ) { $ newObjectStates = $ this -> inputDispatcher -> parse ( new Message ( array ( 'Content-Type' => $ request -> headers -> get ( 'Content-Type' ) ) , $ request -> getContent ( ) ) ) ; $ countByGroups = array ( ) ; foreach ( $ newObjectStates as $ newObjectState ) { $ groupId = ( int ) $ newObjectState -> groupId ; if ( array_key_exists ( $ groupId , $ countByGroups ) ) { ++ $ countByGroups [ $ groupId ] ; } else { $ countByGroups [ $ groupId ] = 1 ; } } foreach ( $ countByGroups as $ groupId => $ count ) { if ( $ count > 1 ) { throw new ForbiddenException ( "Multiple object states provided for group with ID $groupId" ) ; } } $ contentInfo = $ this -> contentService -> loadContentInfo ( $ contentId ) ; $ contentObjectStates = array ( ) ; foreach ( $ newObjectStates as $ newObjectState ) { $ objectStateGroup = $ this -> objectStateService -> loadObjectStateGroup ( $ newObjectState -> groupId ) ; $ this -> objectStateService -> setContentState ( $ contentInfo , $ objectStateGroup , $ newObjectState -> objectState ) ; $ contentObjectStates [ ( int ) $ objectStateGroup -> id ] = $ newObjectState ; } return new ContentObjectStates ( $ contentObjectStates ) ; }
Updates object states of content
An object state in the input overrides the state of the object state group.

@param $contentId

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

@return \eZ\Publish\Core\REST\Common\Values\ContentObjectStates
Updates object states of content An object state in the input overrides the state of the object state group .