eZ\Publish\Core\REST\Client\ObjectStateService::setContentState PHP Method

setContentState() public method

Sets the object-state of a state group to $state for the given content.
public setContentState ( eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo, eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroup $objectStateGroup, eZ\Publish\API\Repository\Values\ObjectState\ObjectState $objectState )
$contentInfo eZ\Publish\API\Repository\Values\Content\ContentInfo
$objectStateGroup eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroup
$objectState eZ\Publish\API\Repository\Values\ObjectState\ObjectState
    public function setContentState(ContentInfo $contentInfo, ObjectStateGroup $objectStateGroup, ObjectState $objectState)
    {
        $inputMessage = $this->outputVisitor->visit(new ContentObjectStates(array($objectState)));
        $inputMessage->headers['Accept'] = $this->outputVisitor->getMediaType('ContentObjectStates');
        $inputMessage->headers['X-HTTP-Method-Override'] = 'PATCH';
        // Should originally be PATCH, but PHP's shiny new internal web server
        // dies with it.
        $values = $this->requestParser->parse('object', $contentInfo->id);
        $result = $this->client->request('POST', $this->requestParser->generate('objectObjectStates', array('object' => $values['object'])), $inputMessage);
        $this->inputDispatcher->parse($result);
    }