protected function processTaggedServices(ContainerBuilder $container, $manager, $tag, $method, $params = array())
    {
        if (!$container->hasDefinition($manager)) {
            return;
        }

        $definition = $container->getDefinition($manager);

        $taggedServices = $container->findTaggedServiceIds($tag);

        foreach ($taggedServices as $id => $attributes) {
            $methodParams = array();

            if (!empty($attributes)) {
                foreach ($params as $param) {
                    if (isset($attributes[0][$param])) {
                        $methodParams[] = $attributes[0][$param];
                    }
                }
            }

            $definition->addMethodCall(
                $method,
                array_merge(array(new Reference($id), $id), $methodParams)
            );
        }
    }