eZ\Publish\Core\REST\Server\Controller\ObjectState::setObjectStatesForContent PHP Метод

setObjectStatesForContent() публичный Метод

Updates object states of content An object state in the input overrides the state of the object state group.
public setObjectStatesForContent ( $contentId, Request $request ) : ContentObjectStates
$contentId
$request Symfony\Component\HttpFoundation\Request
Результат eZ\Publish\Core\REST\Common\Values\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);
    }