/**
  * Creates a resource owner service.
  *
  * @example code
  * $extension = $container->getExtension('glory_oauth');
  * $extension->createOwnerService($container,$name,[]);
  * 
  * @param ContainerBuilder $container The container builder
  * @param string           $name      The name of the service
  * @param array            $options   Additional options of the service
  */
 public function createOwnerService(ContainerBuilder $container, $name, array $options)
 {
     $ownerId = 'glory_oauth.owner.' . $name;
     // alias services
     if (isset($options['service'])) {
         // set the appropriate name for aliased services, compiler pass depends on it
         $container->setAlias($ownerId, $options['service']);
     } else {
         $type = $options['type'];
         unset($options['type']);
         $definition = new DefinitionDecorator('glory_oauth.owner.abstract_' . GloryOAuthSupport::getOwnerType($type));
         $definition->setClass("%glory_oauth.owner.{$type}.class%");
         $container->setDefinition($ownerId, $definition);
         $definition->replaceArgument(2, $options)->replaceArgument(3, $name);
     }
     $container->getDefinition('glory_oauth.ownermap')->addMethodCall('addOwner', array($name, new Reference($ownerId)));
 }