Hi,
I’m trying to remove all the regions within a layout via the PHP API.
Here is the code for it:
$xRegion = (new \Xibo\OAuth2\Client\Entity\XiboRegion($this->EP));
$xLayout = (new \Xibo\OAuth2\Client\Entity\XiboLayout($this->EP))->getById($layout['layoutXiboId'], 'regions,playlists,widgets');
if($xLayout->publishedStatusId == XiboPublishedStatus::PUBLISHED)
$xLayoutCheckout = $xLayout->checkout($xLayout->layoutId);
else if($xLayout->publishedStatusId == XiboPublishedStatus::DRAFT){
$xLayoutCheckout = $xLayout;
}
//Delete all the regions it contains
foreach($xLayoutCheckout->regions as $key => $region){
$xRegion->delete($region->regionId);
}
Before the first if/else block, I printed the content of the “$xLayout” object and it showed me that the XiboPublishedId is 2 which is a draft.
However when it reaches the delete region function, it throws an error telling me the layout is not a draft.
I tried to checkout the layout before that function and it throws an error telling me the layout is already checked out…
Also, I don’t know if this could explain the bug, but when I print the checked out layout object, the parentId is equal to 0 (the layoutId is 5598)