Ejemplo n.º 1
0
 protected function wrapServiceConditionals($value, $code)
 {
     if (!($services = ContainerBuilder::getServiceConditionals($value))) {
         return $code;
     }
     $conditions = array();
     foreach ($services as $service) {
         $conditions[] = sprintf("\$this->has('%s')", $service);
     }
     // re-indent the wrapped code
     $code = implode("\n", array_map(function ($line) {
         return $line ? '    ' . $line : $line;
     }, explode("\n", $code)));
     return sprintf("        if (%s) {\n%s        }\n", implode(' && ', $conditions), $code);
 }