private function readConditions(): void
{
+ $pageConditionObjectTypeID = ObjectTypeCache::getInstance()->getObjectTypeIDByName(
+ Box::VISIBILITY_CONDITIONS_OBJECT_TYPE_NAME,
+ 'com.woltlab.wcf.page'
+ );
+
+ $this->pageIDs = $this->visibleEverywhere = null;
foreach ($this->groupedConditionObjectTypes as $groupedObjectTypes) {
foreach ($groupedObjectTypes as $objectTypes) {
if (\is_array($objectTypes)) {
foreach ($objectTypes as $objectType) {
$objectType->getProcessor()->readFormParameters();
- if ($objectType->getProcessor() instanceof MultiPageCondition) {
+ if ($objectType->objectTypeID == $pageConditionObjectTypeID) {
+ \assert($objectTypes->getProcessor() instanceof MultiPageCondition);
+
$data = $objectType->getProcessor()->getData();
if ($data !== null) {
$this->pageIDs = $data['pageIDs'];
- $this->visibleEverywhere = !$data['pageIDs_reverseLogic'];
+ $this->visibleEverywhere = !$data['pageIDs_reverseLogic'] ? 1 : 0;
+ } else {
+ $this->pageIDs = [];
+ $this->visibleEverywhere = 1;
}
}
}
} else {
$objectTypes->getProcessor()->readFormParameters();
- if ($objectTypes->getProcessor() instanceof MultiPageCondition) {
+ if ($objectTypes->objectTypeID == $pageConditionObjectTypeID) {
+ \assert($objectTypes->getProcessor() instanceof MultiPageCondition);
+
$data = $objectTypes->getProcessor()->getData();
if ($data !== null) {
$this->pageIDs = $data['pageIDs'];
- $this->visibleEverywhere = !$data['pageIDs_reverseLogic'];
+ $this->visibleEverywhere = !$data['pageIDs_reverseLogic'] ? 1 : 0;
+ } else {
+ $this->pageIDs = [];
+ $this->visibleEverywhere = 1;
}
}
}
}
}
+
+ if ($this->pageIDs === null || $this->visibleEverywhere === null) {
+ throw new \LogicException(
+ \sprintf(
+ "The '%d' condition for the definition '%d' is missing.",
+ 'com.woltlab.wcf.page',
+ Box::VISIBILITY_CONDITIONS_OBJECT_TYPE_NAME
+ )
+ );
+ }
}
/**
*/
public function readData()
{
- $objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.condition.box');
+ $objectTypes = ObjectTypeCache::getInstance()->getObjectTypes(Box::VISIBILITY_CONDITIONS_OBJECT_TYPE_NAME);
foreach ($objectTypes as $objectType) {
if (!$objectType->conditionobject) {
continue;
}
$conditionObjectTypeID = ObjectTypeCache::getInstance()->getObjectTypeIDByName(
- 'com.woltlab.wcf.condition.box',
+ Box::VISIBILITY_CONDITIONS_OBJECT_TYPE_NAME,
'com.woltlab.wcf.page'
);
$oldCondition = [];
private function createPageConditions(array $pages, bool $reverseLogic, Box $box): array
{
$pageCondition = ObjectTypeCache::getInstance()->getObjectTypeByName(
- 'com.woltlab.wcf.condition.box',
+ Box::VISIBILITY_CONDITIONS_OBJECT_TYPE_NAME,
'com.woltlab.wcf.page'
);
- $pageIDs = \array_merge($box->getPageIDs(), \array_map(static function ($page) {
- return $page->pageID;
- }, $pages));
+ $pageIDs = \array_merge(
+ $box->getPageIDs(),
+ \array_column($pages, 'pageID')
+ );
\assert($pageCondition->getProcessor() instanceof MultiPageCondition);