public function onInitIDAttribute($event)
    {
        $sender = $event->sender;
        /* @var $sender static */
        if ($sender->idPreassigned) {
            return;
        }
        if ($sender->idAttributeType === static::$idTypeAutoIncrement) {
            $sender->idAttributeSafe = true;
            return;
        }
        $idAttribute = $sender->idAttribute;
        if (is_string($idAttribute) && !empty($idAttribute) &&
            is_int($sender->idAttributeLength) &&
            $sender->idAttributeLength > 0) {
            $sender->setID($sender->generateId());
        }
    }
public function onInitIDAttribute($event)
    {
        $sender = $event->sender;
        /* @var $sender static */
        if ($sender->idPreassigned) {
            return;
        }
        if ($sender->idAttributeType === static::$idTypeAutoIncrement) {
            $sender->idAttributeSafe = true;
            return;
        }
        $idAttribute = $sender->idAttribute;
        if (is_string($idAttribute) && !empty($idAttribute) &&
            is_int($sender->idAttributeLength) &&
            $sender->idAttributeLength > 0) {
            $sender->setID($sender->generateId());
        }
    }
public function onInitIDAttribute ( $ event ) { $ sender = $ event -> sender ; /* @var $sender static */ if ( $ sender -> idPreassigned ) { return ; } if ( $ sender -> idAttributeType === static :: $ idTypeAutoIncrement ) { $ sender -> idAttributeSafe = true ; return ; } $ idAttribute = $ sender -> idAttribute ; if ( is_string ( $ idAttribute ) && ! empty ( $ idAttribute ) && is_int ( $ sender -> idAttributeLength ) && $ sender -> idAttributeLength > 0 ) { $ sender -> setID ( $ sender -> generateId ( ) ) ; } }
Initialize the ID attribute with new generated ID.
If the model's id is pre-assigned, then it will return directly.
If the model's id is auto-increment, the id attribute will be marked safe.
This method is ONLY used for being triggered by event. DO NOT call,
override or modify it directly, unless you know the consequences.
@param ModelEvent $event
Initialize the ID attribute with new generated ID . If the model s id is pre - assigned then it will return directly . If the model s id is auto - increment the id attribute will be marked safe . This method is ONLY used for being triggered by event . DO NOT call override or modify it directly unless you know the consequences .