src/forms/EmployeeForm.php
protected function contactLocalization($originalContact, $language, $createWhenNotExists = true)
    {
        $originalContact->scenario = $this->scenario;

        if ($language === self::LANGUAGE_DEFAULT) {
            $originalContact->localization = $language;

            return $originalContact;
        }

        foreach ($originalContact->localizations as $contact) {
            if ($contact->localization === $language) {
                $contact->scenario = $this->scenario;

                return $contact;
            }
        }

        if (!$createWhenNotExists) {
            return null;
        }

        /** @var Contact $model */
        $model = clone $originalContact;
        $model->setAttributes([
            'id' => null,
            'type' => 'localized',
            'localization' => $language,
        ]);

        return $model;
    }
protected function contactLocalization($originalContact, $language, $createWhenNotExists = true)
    {
        $originalContact->scenario = $this->scenario;

        if ($language === self::LANGUAGE_DEFAULT) {
            $originalContact->localization = $language;

            return $originalContact;
        }

        foreach ($originalContact->localizations as $contact) {
            if ($contact->localization === $language) {
                $contact->scenario = $this->scenario;

                return $contact;
            }
        }

        if (!$createWhenNotExists) {
            return null;
        }

        /** @var Contact $model */
        $model = clone $originalContact;
        $model->setAttributes([
            'id' => null,
            'type' => 'localized',
            'localization' => $language,
        ]);

        return $model;
    }
protected function contactLocalization ( $ originalContact , $ language , $ createWhenNotExists = true ) { $ originalContact -> scenario = $ this -> scenario ; if ( $ language === self :: LANGUAGE_DEFAULT ) { $ originalContact -> localization = $ language ; return $ originalContact ; } foreach ( $ originalContact -> localizations as $ contact ) { if ( $ contact -> localization === $ language ) { $ contact -> scenario = $ this -> scenario ; return $ contact ; } } if ( ! $ createWhenNotExists ) { return null ; } /** @var Contact $model */ $ model = clone $ originalContact ; $ model -> setAttributes ( [ 'id' => null , 'type' => 'localized' , 'localization' => $ language , ] ) ; return $ model ; }
Gets localized version of this contact.

@param $originalContact
@param $language
@param bool $createWhenNotExists
@return Contact
Gets localized version of this contact .