private function addServiceConfigurator(Definition $definition, $variableName = 'instance')
    {
        if (!$callable = $definition->getConfigurator()) {
            return '';
        }

        if (is_array($callable)) {
            if ($callable[0] instanceof Reference
                || ($callable[0] instanceof Definition && $this->definitionVariables->contains($callable[0]))) {
                return sprintf("        %s->%s(\$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName);
            }

            $class = $this->dumpValue($callable[0]);
            // If the class is a string we can optimize call_user_func away
            if (0 === strpos($class, "'") && false === strpos($class, '$')) {
                return sprintf("        %s::%s(\$%s);\n", $this->dumpLiteralClass($class), $callable[1], $variableName);
            }

            if (0 === strpos($class, 'new ')) {
                return sprintf("        (%s)->%s(\$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName);
            }

            return sprintf("        \\call_user_func(array(%s, '%s'), \$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName);
        }

        return sprintf("        %s(\$%s);\n", $callable, $variableName);
    }
private function addServiceConfigurator(Definition $definition, $variableName = 'instance')
    {
        if (!$callable = $definition->getConfigurator()) {
            return '';
        }

        if (is_array($callable)) {
            if ($callable[0] instanceof Reference
                || ($callable[0] instanceof Definition && $this->definitionVariables->contains($callable[0]))) {
                return sprintf("        %s->%s(\$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName);
            }

            $class = $this->dumpValue($callable[0]);
            // If the class is a string we can optimize call_user_func away
            if (0 === strpos($class, "'") && false === strpos($class, '$')) {
                return sprintf("        %s::%s(\$%s);\n", $this->dumpLiteralClass($class), $callable[1], $variableName);
            }

            if (0 === strpos($class, 'new ')) {
                return sprintf("        (%s)->%s(\$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName);
            }

            return sprintf("        \\call_user_func(array(%s, '%s'), \$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName);
        }

        return sprintf("        %s(\$%s);\n", $callable, $variableName);
    }
private function addServiceConfigurator ( Definition $ definition , $ variableName = 'instance' ) { if ( ! $ callable = $ definition -> getConfigurator ( ) ) { return '' ; } if ( is_array ( $ callable ) ) { if ( $ callable [ 0 ] instanceof Reference || ( $ callable [ 0 ] instanceof Definition && $ this -> definitionVariables -> contains ( $ callable [ 0 ] ) ) ) { return sprintf ( "        %s->%s(\$%s);\n" , $ this -> dumpValue ( $ callable [ 0 ] ) , $ callable [ 1 ] , $ variableName ) ; } $ class = $ this -> dumpValue ( $ callable [ 0 ] ) ; // If the class is a string we can optimize call_user_func away if ( 0 === strpos ( $ class , "'" ) && false === strpos ( $ class , '$' ) ) { return sprintf ( "        %s::%s(\$%s);\n" , $ this -> dumpLiteralClass ( $ class ) , $ callable [ 1 ] , $ variableName ) ; } if ( 0 === strpos ( $ class , 'new ' ) ) { return sprintf ( "        (%s)->%s(\$%s);\n" , $ this -> dumpValue ( $ callable [ 0 ] ) , $ callable [ 1 ] , $ variableName ) ; } return sprintf ( "        \\call_user_func(array(%s, '%s'), \$%s);\n" , $ this -> dumpValue ( $ callable [ 0 ] ) , $ callable [ 1 ] , $ variableName ) ; } return sprintf ( "        %s(\$%s);\n" , $ callable , $ variableName ) ; }
Adds configurator definition.

@param Definition $definition
@param string     $variableName

@return string
Adds configurator definition .