Stored two fields into one

I need to store two fields in one separated by a space. What function is used for this?

I tried beforeMarshal, but it validates that the fields must not contain spaces, because one field can only contain numbers without spaces. I would like the two fields to merge before saving and there is a space between them. Please how to do it?

Maybe define 2 virtual fields in entity and merge them into “real” sql one in beforeMarshal?

Thank You, i make with beforeSave method…

    /**
     * beforeSave configuration.
     *
     * @param EventInterface $event
     * @param EntityInterface $entity
     */
    public function beforeSave(EventInterface $event, EntityInterface $entity)
    {
        $phone_preset = $entity->get('phone_preset');
        $phone = $entity->get('phone');
        if (!empty($phone_preset) && !empty($phone)) {
            $entity->set('phone', $phone_preset . ' ' . $phone);
        }

        $phone_home_preset = $entity->get('phone_home_preset');
        $phone_home = $entity->get('phone_home');
        if (!empty($phone_home_preset) && !empty($phone_home)) {
            $entity->set('phone_home', $phone_home_preset . ' ' . $phone_home);
        } else {
            $entity->set('phone_home', null);
        }
    }