protected function setViewVars(
        ControllerInterface $controller, ServerRequestInterface $request
    ) {
        $key = $controller::REQUEST_ATTR_VIEW_DATA;
        $data = $request->getAttribute($key, []);
        $request = $request->withAttribute(
            $key,
            array_merge($data, $controller->getViewVars())
        );
        return $request;
    }