/**
  * @param PhpClassComponentDefinition $definition
  * @param ComponentNode $node
  * @param SourceCompilerInterface $sourceCompiler
  * @return string
  *
  * @throws CompileException
  */
 protected function compileParameters(PhpClassComponentDefinition $definition, ComponentNode $node, SourceCompilerInterface $sourceCompiler)
 {
     $result = [];
     $values = $node->parameters;
     foreach ($definition->getMethodParameters() as $param_definition) {
         $name = $param_definition->getName();
         // support attributes passing
         if ($name === '__attrs') {
             $result[] = $sourceCompiler->compileParametersArray($node->parameters);
             // support content passing
         } elseif ($name === '__content') {
             if ($node instanceof ContainerComponentNode) {
                 $result[] = $sourceCompiler->compileNode($sourceCompiler->buildContentClosure($node->innerNodes));
             } else {
                 $result[] = 'null';
             }
             // support regular parameters
         } elseif (isset($values[$name])) {
             $value = $values[$name];
             $result[] = $sourceCompiler->compileNode($value);
             // no value, check if parameter has default value
         } elseif (!$param_definition->isRequired()) {
             $result[] = var_export($param_definition->getDefaultValue() ?: null);
         } else {
             throw new CompileException(sprintf('Missing required parameter: "%s" for component <%s>', $name, $definition->getName()));
         }
     }
     return implode(', ', $result);
 }
 /**
  * Compile given component's Node to string
  *
  * @param ComponentNode $node
  * @param ComponentDefinition|PhpTemplateComponentDefinition $definition
  * @param SourceCompilerInterface $sourceCompiler
  * @return string
  */
 public function compileComponent(ComponentNode $node, ComponentDefinition $definition, SourceCompilerInterface $sourceCompiler)
 {
     if ($node instanceof ContainerComponentNode) {
         $content = $sourceCompiler->buildContentClosure($node->innerNodes);
     } else {
         $content = null;
     }
     return sprintf(static::CALL_CODE_TEMPLATE, var_export(realpath($definition->getFile()), true), $sourceCompiler->compileParametersArray($node->parameters), $content ? $sourceCompiler->compileNode($content) : 'null');
 }
 /**
  * Compile given component's Node to string
  *
  * @param ComponentNode $node
  * @param ComponentDefinition $definition
  * @param SourceCompilerInterface $sourceCompiler
  * @return string
  */
 public function compileComponent(ComponentNode $node, ComponentDefinition $definition, SourceCompilerInterface $sourceCompiler)
 {
     $parameters = $node->parameters;
     if ($node instanceof ContainerComponentNode) {
         $content = $sourceCompiler->buildContentClosure($node->innerNodes);
         $parameters[] = new ArrayItem($content, new String_('_content'));
     }
     return $this->getCallComponentCode($node, $definition, $sourceCompiler->compileParametersArray($parameters));
 }