code: private function getPublicRequireDefinition(ContainerBuilder $container, $id, $type)
      {
          $serviceDefinition = $container->getDefinition($id);
  
          if (!$serviceDefinition->isPublic()) {
              throw new InvalidArgumentException(sprintf('The service "%s" must be public as block %s are lazy-loaded.', $id, $type));
          }
  
          return $serviceDefinition;
      }
docs: Get the service definition and validate if the service is public.
  
  @param ContainerBuilder $container The container builder
  @param string           $id        The service id
  @param string           $type      The block type
  
  @return Definition
  
  @throws InvalidArgumentException When the service is not public