container = $container; $this->entityManagerProxy = $entityManagerProxy; } /** * Set up the system user as a current user. The system user is used when no user is logged in. */ public function setupSystemUser(): void { $user = $this->entityManagerProxy->getEntityById(User::ENTITY_TYPE, self::SYSTEM_USER_ID); if (!$user) { throw new RuntimeException("System user is not found."); } $user->set('ipAddress', $_SERVER['REMOTE_ADDR'] ?? null); $user->set('type', User::TYPE_SYSTEM); $this->container->set('user', $user); } /** * Set a current user. */ public function setUser(User $user): void { $this->container->set('user', $user); } }