*/ class UserGroupCollection extends FlexCollection { /** * @return array */ public static function getCachedMethods(): array { return [ 'authorize' => false, ] + parent::getCachedMethods(); } /** * Checks user authorization to the action. * * @param string $action * @param string|null $scope * @return bool|null */ public function authorize(string $action, string $scope = null): ?bool { $authorized = null; /** @var UserGroupObject $object */ foreach ($this as $object) { $auth = $object->authorize($action, $scope); if ($auth === true) { $authorized = true; } elseif ($auth === false) { return false; } } return $authorized; } }