Skip to content

Model

Model provides a convention for separating business logic from application logic.

When using a model you’re providing a globally accessible API for other modules to access, which will boost interoperability among modules in your web application.

abstract class Model implements IModel

ImplementsIModel
Since1.0.0
SourceModel/Model.php
PropertyTypeDescription
$_contextNamemixedprotected.
$contextmixedprotected.
MethodDescription
__sleep(): mixedPre-serialization callback.
__wakeup(): mixedPost-unserialization callback.
getContext(): ContextRetrieve the current application context.
initialize(Context $context, array<array-key, mixed> $parameters = []): voidInitialize this model.

public function __sleep(): mixed

Pre-serialization callback.

Will set the name of the context and exclude the instance from serializing.

Returns mixed

public function __wakeup(): mixed

Post-unserialization callback.

Will restore the context based on the names set by __sleep.

Returns mixed

final public function getContext(): Context

Retrieve the current application context.

Returns Context — The current Context instance.

public function initialize(Context $context, array<array-key, mixed> $parameters = []): void

Initialize this model.

Initialization parameters. The same array the locator spreads into the constructor when the class declares one, so it is positional as often as it is associative.

ParameterTypeDescription
$contextContextThe current application context.
$parametersarray``<``array-key``, ``mixed``>Initialization parameters. The same array the locator spreads into the constructor when the class declares one, so it is positional as often as it is associative.