- Add comprehensive health check system with multiple endpoints - Add Prometheus metrics endpoint - Add production logging configurations (5 strategies) - Add complete deployment documentation suite: * QUICKSTART.md - 30-minute deployment guide * DEPLOYMENT_CHECKLIST.md - Printable verification checklist * DEPLOYMENT_WORKFLOW.md - Complete deployment lifecycle * PRODUCTION_DEPLOYMENT.md - Comprehensive technical reference * production-logging.md - Logging configuration guide * ANSIBLE_DEPLOYMENT.md - Infrastructure as Code automation * README.md - Navigation hub * DEPLOYMENT_SUMMARY.md - Executive summary - Add deployment scripts and automation - Add DEPLOYMENT_PLAN.md - Concrete plan for immediate deployment - Update README with production-ready features All production infrastructure is now complete and ready for deployment.
68 lines
2.0 KiB
PHP
68 lines
2.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Framework\View;
|
|
|
|
use App\Framework\View\Contracts\StaticComponent;
|
|
use App\Framework\View\Dom\Renderer\HtmlRenderer;
|
|
|
|
/**
|
|
* StaticComponentRenderer
|
|
*
|
|
* Renders StaticComponents to HTML strings.
|
|
* Counterpart to LiveComponentRenderer for server-side static components.
|
|
*
|
|
* Rendering Flow:
|
|
* 1. Instantiate StaticComponent with content + attributes
|
|
* 2. Component returns Node tree via getRootNode()
|
|
* 3. HtmlRenderer converts tree to HTML string
|
|
*
|
|
* Example:
|
|
* ```php
|
|
* $renderer = new StaticComponentRenderer($htmlRenderer);
|
|
*
|
|
* $html = $renderer->render(
|
|
* componentClass: Button::class,
|
|
* content: 'Click Me',
|
|
* attributes: ['variant' => 'primary']
|
|
* );
|
|
* // Returns: <button class="btn btn-primary">Click Me</button>
|
|
* ```
|
|
*/
|
|
final readonly class StaticComponentRenderer
|
|
{
|
|
public function __construct(
|
|
private HtmlRenderer $htmlRenderer = new HtmlRenderer()
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* Render a StaticComponent to HTML
|
|
*
|
|
* @param class-string<StaticComponent> $componentClass Fully qualified component class name
|
|
* @param string $content Inner HTML content from template
|
|
* @param array<string, string> $attributes Key-value attributes from template
|
|
* @return string Rendered HTML
|
|
* @throws \RuntimeException If class does not implement StaticComponent
|
|
*/
|
|
public function render(string $componentClass, string $content, array $attributes = []): string
|
|
{
|
|
// Verify it's a StaticComponent
|
|
if (! is_subclass_of($componentClass, StaticComponent::class)) {
|
|
throw new \RuntimeException(
|
|
"Class {$componentClass} does not implement StaticComponent interface"
|
|
);
|
|
}
|
|
|
|
// Instantiate StaticComponent with content + attributes
|
|
$component = new $componentClass($content, $attributes);
|
|
|
|
// Get root node tree from component
|
|
$rootNode = $component->getRootNode();
|
|
|
|
// Render tree to HTML string
|
|
return $this->htmlRenderer->render($rootNode);
|
|
}
|
|
}
|