function getDefaultValue($name) { if (!$this->macroInstance) { $this->noMacro(); } $param = $this->macroInstance->getParameter($name, $found); if (!$found) { throw new ComponentException($this->component, "Undefined macro parameter <kbd>{$name}</kbd>.\n<p>Available parameters: <b>" . implode(', ', $this->component->props->getPropertyNames()) . '</b>'); } $v = $param->getComputedPropValue('default'); if (isset($v) && $v !== '' && $param->props->type == 'content') { $meta = new Metadata($this->macroInstance->context, ucfirst($name), type::content); $meta->attachTo($this->component); $meta->addChild(Text::from($this->macroInstance->context, $v)); return $meta; } return $v; }
private function subtag_createSlotContent($propName, $tagName, array $attributes = null, array $bindings = null) { $component = $this->current; $type = $component->props->getTypeOf($propName); if ($type == type::string) { $this->currentScalarProperty = $propName; } else { $relatedType = $type == type::collection ? $component->props->getRelatedTypeOf($propName) : ''; $this->current = $param = new Metadata($component->context, $tagName, $relatedType ?: $type, $attributes); $param->attachTo($component); switch ($type) { case type::content: $component->props->{$propName} = $param; $param->setBindings($bindings); break; case type::metadata: $component->props->{$propName} = $param; $param->setBindings($bindings); if (!$this->metadataContainer) { $this->metadataContainer = $param; } break; case type::collection: if (isset($component->props->{$propName})) { $component->props->{$propName}[] = $param; } else { $component->props->{$propName} = [$param]; } $param->setBindings($bindings); if ($relatedType == type::metadata) { $this->metadataContainer = $param; } break; default: $this->parsingError("Invalid subtag <kbd>{$tagName}</kbd>"); } } }