public function getPolicy($resource)
    {
        if ($resource instanceof EntityInterface) {
            return $this->getEntityPolicy($resource);
        }
        if ($resource instanceof RepositoryInterface) {
            return $this->getRepositoryPolicy($resource);
        }
        if ($resource instanceof QueryInterface) {
            return $this->getRepositoryPolicy($resource->repository());
        }
        $name = is_object($resource) ? get_class($resource) : gettype($resource);
        throw new MissingPolicyException([$name]);
    }