Files
michaelschiemer/src/Framework/LiveComponents/FormBuilder/MultiStepFormState.php
Michael Schiemer fc3d7e6357 feat(Production): Complete production deployment infrastructure
- 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.
2025-10-25 19:18:37 +02:00

137 lines
3.4 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Framework\LiveComponents\FormBuilder;
use App\Application\LiveComponents\LiveComponentState;
/**
* MultiStepFormState - Immutable state for multi-step form component
*/
final readonly class MultiStepFormState implements LiveComponentState
{
public function __construct(
public int $currentStep = 1,
public array $formData = [],
public array $errors = [],
public bool $submitted = false,
public ?string $submissionId = null
) {}
public static function fromArray(array $data): self
{
return new self(
currentStep: $data['current_step'] ?? 1,
formData: $data['form_data'] ?? [],
errors: $data['errors'] ?? [],
submitted: $data['submitted'] ?? false,
submissionId: $data['submission_id'] ?? null
);
}
public function toArray(): array
{
return [
'current_step' => $this->currentStep,
'form_data' => $this->formData,
'errors' => $this->errors,
'submitted' => $this->submitted,
'submission_id' => $this->submissionId,
];
}
// Transformation methods for immutable state changes
public function withFieldUpdate(string $field, mixed $value): self
{
$newFormData = $this->formData;
$newFormData[$field] = $value;
return new self(
currentStep: $this->currentStep,
formData: $newFormData,
errors: $this->errors,
submitted: $this->submitted,
submissionId: $this->submissionId
);
}
public function withNextStep(): self
{
return new self(
currentStep: $this->currentStep + 1,
formData: $this->formData,
errors: [],
submitted: $this->submitted,
submissionId: $this->submissionId
);
}
public function withPreviousStep(): self
{
return new self(
currentStep: max(1, $this->currentStep - 1),
formData: $this->formData,
errors: [],
submitted: $this->submitted,
submissionId: $this->submissionId
);
}
public function withErrors(array $errors): self
{
return new self(
currentStep: $this->currentStep,
formData: $this->formData,
errors: $errors,
submitted: $this->submitted,
submissionId: $this->submissionId
);
}
public function withSubmitted(string $submissionId): self
{
return new self(
currentStep: $this->currentStep,
formData: $this->formData,
errors: [],
submitted: true,
submissionId: $submissionId
);
}
public function withReset(): self
{
return new self(
currentStep: 1,
formData: [],
errors: [],
submitted: false,
submissionId: null
);
}
// Query methods
public function hasErrors(): bool
{
return !empty($this->errors);
}
public function getFieldValue(string $field): mixed
{
return $this->formData[$field] ?? null;
}
public function isFirstStep(): bool
{
return $this->currentStep === 1;
}
public function isCompleted(): bool
{
return $this->submitted;
}
}