/**
  * {@inheritDoc}
  */
 public function process(ContainerBuilder $container)
 {
     foreach ($container->findTaggedServiceIds('api.error') as $id => $tags) {
         foreach ($tags as $index => $attributes) {
             try {
                 if (empty($attributes['handler'])) {
                     throw new \RuntimeException('Missing required attribute "handler"');
                 }
                 $handlerId = $this->handlerPass->getHandlerId($attributes['handler']);
                 $errorId = $this->handlerPass->getErrors($handlerId);
                 $errorDefinition = $container->getDefinition($errorId);
                 $factoryDefinition = $container->getDefinition($id);
                 $class = $factoryDefinition->getClass();
                 $class = $container->getParameterBag()->resolveValue($class);
                 $refClass = new \ReflectionClass($class);
                 $requiredInterface = 'FivePercent\\Component\\Error\\ErrorFactoryInterface';
                 if (!$refClass->implementsInterface($requiredInterface)) {
                     throw new \RuntimeException(sprintf('The error factory should implement "%s" interface.', $requiredInterface));
                 }
                 $errorDefinition->addMethodCall('addFactory', [new Reference($id)]);
             } catch (\Exception $e) {
                 throw new \RuntimeException(sprintf('Could not compile error factory for tag index "%d" and service id "%s".', $index, $id), 0, $e);
             }
         }
     }
 }
 /**
  * {@inheritDoc}
  */
 public function process(ContainerBuilder $container)
 {
     foreach ($container->findTaggedServiceIds('api.action') as $id => $tags) {
         foreach ($tags as $index => $attributes) {
             try {
                 if (empty($attributes['handler'])) {
                     throw new \RuntimeException('Missing required attribute "handler".');
                 }
                 $handlerId = $this->handlerPass->getHandlerId($attributes['handler']);
                 $this->processByAnnotation($container, $id, $handlerId);
             } catch (\Exception $e) {
                 throw new \RuntimeException(sprintf('Could not compile API action for tag index "%d" and service id "%s".', $index, $id), 0, $e);
             }
         }
     }
 }