0 follower

Class Yiisoft\ActiveRecord\Event\Handler\DefaultValueOnInsert

InheritanceYiisoft\ActiveRecord\Event\Handler\DefaultValueOnInsert » Yiisoft\ActiveRecord\Event\Handler\AttributeHandlerProvider
SubclassesYiisoft\ActiveRecord\Event\Handler\DefaultDateTimeOnInsert

Attribute for setting default value for properties before inserting a new record into the database.

It can be applied to classes or properties, and it can be repeated for multiple properties.

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( mixed $value null, string $propertyNames )
$value mixed
$propertyNames string

                public function __construct(
    private readonly mixed $value = null,
    string ...$propertyNames,
) {
    parent::__construct(...$propertyNames);
}

            
getEventHandlers() public method

public array getEventHandlers ( )

                public function getEventHandlers(): array
{
    return [
        BeforeInsert::class => $this->beforeInsert(...),
        BeforeUpsert::class => $this->beforeUpsert(...),
    ];
}

            
getPropertyNames() public method

Defined in: Yiisoft\ActiveRecord\Event\Handler\AttributeHandlerProvider::getPropertyNames()

Returns the list of property names the handler should be applied to.

public string[] getPropertyNames ( )

                public function getPropertyNames(): array
{
    return $this->propertyNames;
}

            
setPropertyNames() public method

Defined in: Yiisoft\ActiveRecord\Event\Handler\AttributeHandlerProvider::setPropertyNames()

Sets the list of property names the handler should be applied to.

public void setPropertyNames ( string[] $propertyNames )
$propertyNames string[]

                public function setPropertyNames(array $propertyNames): void
{
    $this->propertyNames = $propertyNames;
}