Skip to content

StickyAssignmentMiddleware ​

Rasuvaeff\Yii3AbTestingWeb\StickyAssignmentMiddleware

Class · rasuvaeff/yii3-ab-testing-web · Source

Creates the request-scoped signed-cookie store and sticky resolver, exposes both through StickyAssignmentRequestAccessor, then applies store changes to the response.

Run after SubjectIdMiddleware.

Constructor ​

php
new StickyAssignmentMiddleware(
    AssignmentResolver $resolver,
    Yiisoft\Cookies\CookieSigner $signer,
    ConsentPolicyInterface $consentPolicy = new AllowAllConsentPolicy(),
    SubjectIdRequestAccessor $subjectIdAccessor = new SubjectIdRequestAccessor(),
    StickyAssignmentRequestAccessor $stickyAccessor = new StickyAssignmentRequestAccessor(),
    string $cookieName = 'ab_variants',
    int $maxEntries = 50,
    int $maxCookieBytes = 3800,
)

Methods ​

process() ​

php
process(
    Psr\Http\Message\ServerRequestInterface $request,
    Psr\Http\Server\RequestHandlerInterface $handler,
): Psr\Http\Message\ResponseInterface