/** * @param string $tableName The table name to build constraints for * @param string $fieldName The field name to build constraints for * * @return CompositeExpression */ protected function getFrontendUserGroupConstraints(string $tableName, string $fieldName) : CompositeExpression { $expressionBuilder = $this->expressionBuilder; // Allow records where no group access has been configured (field values NULL, 0 or empty string) $constraints = [$expressionBuilder->isNull($tableName . '.' . $fieldName), $expressionBuilder->eq($tableName . '.' . $fieldName, $expressionBuilder->literal('')), $expressionBuilder->eq($tableName . '.' . $fieldName, $expressionBuilder->literal('0'))]; foreach ($this->queryContext->getMemberGroups() as $value) { $constraints[] = $expressionBuilder->inSet($tableName . '.' . $fieldName, $expressionBuilder->literal((string) $value)); } return $expressionBuilder->orX(...$constraints); }
/** * @test */ public function getMemberGroupsFallsBackToTSFE() { $GLOBALS['TSFE']->gr_list = '3,5'; $this->assertSame([3, 5], $this->subject->getMemberGroups()); }