Skip to content

Instantly share code, notes, and snippets.

@janit
Last active December 13, 2016 14:25
Show Gist options
  • Save janit/e19bcf579a7535562c3c19e39f647028 to your computer and use it in GitHub Desktop.
Save janit/e19bcf579a7535562c3c19e39f647028 to your computer and use it in GitHub Desktop.
<?php
$stateId = 3;
$stateService = $this->get('ezpublish.api.service.object_state');
$contentService = $this->get('ezpublish.api.service.content');
$contentInfo = $contentService->loadContentInfo(93);
$objectStateGroup = $stateService->loadObjectStateGroup(4);
$currentState = $stateService->getContentState($contentInfo,$objectStateGroup);
if($currentState->id == 3) {
$stateId = 4;
}
$objectState = $stateService->loadObjectState($stateId);
$stateService->setContentState($contentInfo,$objectStateGroup,$objectState);
dump($currentState);
die();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment