protected function getNewServiceId($oldServiceId)
    {
        if (empty($oldServiceId)) {
            return null;
        }

        $services = $this->package->getResourceFromZip('system/service.json');
        $serviceName = null;
        foreach ($services as $service) {
            if ($oldServiceId === $service['id']) {
                $serviceName = $service['name'];
                break;
            }
        }

        if (!empty($serviceName)) {
            if (!empty($id = ServiceManager::getServiceIdByName($serviceName))) {
                return $id;
            }
        } else {
            if (!empty($serviceName = ServiceManager::getServiceNameById($oldServiceId))) {
                if (in_array($serviceName, ['system', 'api_docs', 'files', 'db', 'email', 'user'])) {
                    // If service is one of the pre-defined system services
                    // then new id is most likely the same as the old id.
                    return $oldServiceId;
                }
            }
        }

        return null;
    }