public function testGetServiceNamespaceWithConvertedServices()
 {
     $converter = new ServiceNameConverter();
     $input = array('abCd', 'dEf');
     $prefix = 'prefix';
     $this->assertEquals('prefix.ab_cd.d_ef', $converter->getServiceNamespace($prefix, $input));
 }
Example #2
0
 /**
  * Magic for getStrategy.
  *
  * @param $method
  * @param $args
  *
  * @return mixed
  *
  * @throws \BadMethodCallException
  */
 public function __call($method, $args)
 {
     $prefix = substr($method, 0, 3);
     if (strcmp($prefix, 'get') != 0) {
         throw new \BadMethodCallException($method);
     }
     $methodName = substr($method, 3);
     $contextName = $this->converter->serviceNameConverter($methodName);
     return call_user_func_array(array($this, 'getStrategy'), array_merge(array($contextName), $args));
 }
Example #3
0
 /**
  * Add a Context.
  *
  * @param ContainerBuilder $container
  * @param string           $prefix
  * @param string           $name
  * @param array            $context
  */
 protected function addContext(ContainerBuilder $container, $prefix, $name, array $context)
 {
     $name = $this->nameConverter->serviceNameConverter($name);
     $serviceName = $prefix . '.' . $name;
     if (isset($context['fallback']) || isset($context['class'])) {
         if (!isset($context['class'])) {
             $context['class'] = 'PUGX\\Godfather\\Context\\Context';
         }
         $context = new Definition($context['class'], array($context['fallback']));
         $container->setDefinition($serviceName, $context);
         return;
     }
     $container->setAlias($serviceName, 'godfather.context');
 }