/** * 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'); }
/** * @param string $file * @param string $name * @param array $parameters * @param bool $is_container */ function __construct($file, $is_container = true, $name = null, $parameters = null) { $this->file = $file; if ($name === null) { $name = $this->guessName($file); } parent::__construct($name, $parameters, $is_container); }
/** * @param ComponentDefinition $component * @return string */ protected function buildComponentSchema(ComponentDefinition $component) { $attributes = []; foreach ($component->getParameters() as $parameter) { $attributes[] = $this->buildComponentAttributeSchema($component, $parameter); } $body = ($component->isContainer() ? ' <xs:sequence> <xs:any minOccurs="0"/> </xs:sequence>' : '') . "\n " . implode("\n ", $attributes) . ($component->isExtraParametersAllowed() ? ' <xs:anyAttribute/>' : ''); return sprintf(' <xs:element name="%s"> <xs:complexType>%s </xs:complexType> </xs:element>', $component->getName(), $body); }
/** * @param string $controller ClassName or ClassName@MethodName * @param string $name */ function __construct($controller, $name = null) { list($this->class, $this->method) = $this->parseControllerSpec($controller); if ($name === null) { $name = $this->guessName($this->class, $this->method); } parent::__construct($name, null); }
function __construct($name = 'Header') { parent::__construct($name, [], true, false); }
/** * @param ComponentNode $node * @param ComponentDefinition|PhpClassComponentDefinition $definition * @param SourceCompilerInterface $sourceCompiler * @return string */ public function compileComponent(ComponentNode $node, ComponentDefinition $definition, SourceCompilerInterface $sourceCompiler) { return sprintf(static::CALL_CODE_TEMPLATE, $definition->getClassName(), $definition->getMethod(), $this->compileParameters($definition, $node, $sourceCompiler)); }