DependencyInjection/Compiler/BlockPass.php
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;
    }
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;
    }
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