eZ\Publish\Core\Persistence\Legacy\Content\ObjectState\Handler::setContentState PHP Method

setContentState() public method

Sets the object-state of a state group to $stateId for the given content.
public setContentState ( mixed $contentId, mixed $groupId, mixed $stateId ) : boolean
$contentId mixed
$groupId mixed
$stateId mixed
return boolean
    public function setContentState($contentId, $groupId, $stateId)
    {
        $this->objectStateGateway->setContentState($contentId, $groupId, $stateId);
        return true;
    }

Usage Example

Example #1
0
 /**
  * @param Content $content
  * @param \eZ\Publish\SPI\Persistence\Content\ObjectState[] $contentStates
  */
 protected function setContentStates(Content $content, array $contentStates)
 {
     foreach ($contentStates as $contentStateGroupId => $contentState) {
         $this->objectStateHandler->setContentState($content->versionInfo->contentInfo->id, $contentStateGroupId, $contentState->id);
     }
 }