- 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.
103 lines
2.6 KiB
PHP
103 lines
2.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Framework\Admin\FormFields\Fields;
|
|
|
|
use App\Framework\Admin\FormFields\Components\FieldWrapper;
|
|
use App\Framework\Admin\FormFields\FormField;
|
|
use App\Framework\Admin\FormFields\ValueObjects\FieldAttributes;
|
|
use App\Framework\Admin\FormFields\ValueObjects\FieldMetadata;
|
|
use App\Framework\View\FormBuilder;
|
|
use App\Framework\View\ValueObjects\FormElement;
|
|
|
|
/**
|
|
* Number Input Field
|
|
*
|
|
* Number input field with min/max/step using composition
|
|
*/
|
|
final readonly class NumberField implements FormField
|
|
{
|
|
public function __construct(
|
|
private FieldMetadata $metadata,
|
|
private FieldAttributes $attributes,
|
|
private FieldWrapper $wrapper,
|
|
private mixed $value = null,
|
|
private ?int $min = null,
|
|
private ?int $max = null,
|
|
private ?int $step = null
|
|
) {
|
|
}
|
|
|
|
public static function create(
|
|
string $name,
|
|
string $label,
|
|
mixed $value = null,
|
|
bool $required = false,
|
|
?string $placeholder = null,
|
|
?string $help = null,
|
|
?int $min = null,
|
|
?int $max = null,
|
|
?int $step = null
|
|
): self {
|
|
return new self(
|
|
metadata: new FieldMetadata($name, $label, $help),
|
|
attributes: new FieldAttributes(
|
|
name: $name,
|
|
id: $name,
|
|
required: $required,
|
|
placeholder: $placeholder
|
|
),
|
|
wrapper: new FieldWrapper(),
|
|
value: $value,
|
|
min: $min,
|
|
max: $max,
|
|
step: $step
|
|
);
|
|
}
|
|
|
|
public function render(FormBuilder $form): FormBuilder
|
|
{
|
|
$additionalAttrs = ['type' => 'number'];
|
|
|
|
if ($this->min !== null) {
|
|
$additionalAttrs['min'] = (string) $this->min;
|
|
}
|
|
|
|
if ($this->max !== null) {
|
|
$additionalAttrs['max'] = (string) $this->max;
|
|
}
|
|
|
|
if ($this->step !== null) {
|
|
$additionalAttrs['step'] = (string) $this->step;
|
|
}
|
|
|
|
$attrs = $this->attributes->withAdditional($additionalAttrs);
|
|
$attrArray = $attrs->toArray();
|
|
|
|
if ($this->value !== null && $this->value !== '') {
|
|
$attrArray['value'] = (string) $this->value;
|
|
}
|
|
|
|
$input = FormElement::create('input', $attrArray);
|
|
$wrapped = $this->wrapper->wrap($input, $this->metadata);
|
|
|
|
return $form->addElement($wrapped);
|
|
}
|
|
|
|
public function getName(): string
|
|
{
|
|
return $this->metadata->name;
|
|
}
|
|
|
|
public function getValue(): mixed
|
|
{
|
|
return $this->value;
|
|
}
|
|
|
|
public function getLabel(): string
|
|
{
|
|
return $this->metadata->label;
|
|
}
|
|
}
|