orchidsoftware / platform

Orchid is a @laravel package that allows for rapid application development of back-office applications, admin/user panels, and dashboards.
https://orchid.software
MIT License
4.45k stars 657 forks source link

Fixed screen constructor property initialization during deserialization #2885

Closed tabuna closed 3 months ago

tabuna commented 3 months ago

When we pass arguments to the constructor for dependency injection, we expect these arguments to be properly initialized and available for use with the object's methods after deserialization.

public function __construct(
    private readonly NewsService $newsService,
    private readonly CatalogService $catalogService,
    private readonly ConstructorService $constructorService
) {
    // ...
}

However, in the current implementation, this can lead to errors such as:

Serialization of 'Closure' is not allowed

This change aims to ensure the reinitialization of the class with all its arguments after deserialization, similar to how it is handled for GET requests. This will help avoid serialization issues and correctly restore the object's state.