A class with this trait will have setDefaults() method that can be passed list of default properties.
$view->setDefaults(['ui' => 'segment']);
Typically you would want to do that inside your constructor. The default handling of the properties is:
Several classes may opt to extend setDefaults, for example in Agile UI setDefaults is extended to support classes and content:
$segment->setDefaults(['Hello There', 'red', 'ui' => 'segment']);
WARNING: Do not use this trait unless you have a lot of properties to inject. Also follow the guidelines on https://github.com/atk4/ui/wiki/Object-Constructors
Relying on this trait excessively may cause anger management issues to some code reviewers.
| Methods | ||
|---|---|---|
public
|
setDefaults(array<string, mixed> $properties, bool $passively = false): $this
|
# |
protected
|
setMissingProperty(string $propertyName, mixed $value): void
|
# |
public
static
|
assertInstanceOf(object $object): static
|
# |
private
static
|
_fromSeedPrecheck(array<mixed>|object $seed, bool $unsafe): array<mixed>|object
|
# |
public
static
|
fromSeed(array<mixed>|object $seed = [], array<mixed> $defaults = []): static
|
# |
public
static
|
fromSeedUnsafe(array<mixed>|object $seed = [], array<mixed> $defaults = []): static
|
# |