/**
  * {@inheritdoc}
  */
 public function process(ContainerBuilder $container)
 {
     if (!$container->hasDefinition('pim_dashboard.widget.registry')) {
         return;
     }
     $definition = $container->getDefinition('pim_dashboard.widget.registry');
     foreach ($container->findTaggedServiceIds('pim_dashboard.widget') as $serviceId => $tag) {
         $alias = isset($tag[0]['alias']) ? $tag[0]['alias'] : $serviceId;
         $definition->addMethodCall('add', array($alias, $this->factory->createReference($serviceId)));
     }
 }
 /**
  * Returns an array of service references for a specified tag name
  *
  * @param string           $tagName
  * @param ContainerBuilder $container
  *
  * @return \Symfony\Component\DependencyInjection\Reference[]
  */
 protected function findAndSortTaggedServices($tagName, ContainerBuilder $container)
 {
     $services = $container->findTaggedServiceIds($tagName);
     if (empty($services)) {
         throw new \RuntimeException(sprintf('You must tag at least one service as "%s" to use the Serializer service', $tagName));
     }
     $sortedServices = array();
     foreach ($services as $serviceId => $tags) {
         foreach ($tags as $tag) {
             $priority = isset($tag['priority']) ? $tag['priority'] : self::DEFAULT_PRIORITY;
             $sortedServices[$priority][] = $this->factory->createReference($serviceId);
         }
     }
     krsort($sortedServices);
     // Flatten the array
     return call_user_func_array('array_merge', $sortedServices);
 }