Bind with i18n model

@param Garp_Model_Db $model
@return Void
498235
public function bindWithI18nModel(Garp_Model_Db $model) {
        $i18nModel = $this->getI18nModel($model);
        $model->bindModel(
            self::I18N_MODEL_BINDING_ALIAS, array(
            'modelClass' => $i18nModel,
            'conditions' => $i18nModel->select()->from(
                $i18nModel->getName(),
                array_merge($this->_translatableFields, array(self::LANG_COLUMN))
            )
            )
        );
    }
732785
public function bind(ViewModelInterface $model)
	{
		$this->scoped['@file'] = $model->getResource();
		$this->scoped['@model'] = $this->model = $model;
		$this->scoped['@context'] = $this;
		
		$this->renderer->triggerContextBound($this);
	}
1254022
public function afterSave($model, $data) {
        // Check if the 'published column' is filled...
        if (empty($data[self::PUBLISHED_COLUMN])) {
            return;
        }

        // ...and that it's in the future
        $publishTime = strtotime($data[self::PUBLISHED_COLUMN]);
        if ($publishTime <= time()) {
            return;
        }

        $tags = array(get_class($model));
        $tags = array_merge($tags, $model->getBindableModels());
        $tags = array_unique($tags);
        Garp_Cache_Manager::scheduleClear($publishTime, $tags);
    }
1279169
protected function prepareVars($model)
    {
        $this->controller->vars['formModel'] = $model;
        $this->controller->vars['formContext'] = $this->formGetContext();
        $this->controller->vars['formRecordName'] = Lang::get($this->getConfig('name', 'backend::lang.model.name'));
    }
356379
public function setModel(\atk4\data\Model $model)
    {
        parent::setModel($model);
        $this->field = $this->field ? $this->field : $this->model->title_field;
        if ($this->autoSave && $this->model->loaded()) {
            if ($this->cb->triggered()) {
                $value = $_POST['value'] ? $_POST['value'] : null;
                $this->cb->set(function () use ($value) {
                    try {
                        $this->model[$this->field] = $this->app->ui_persistence->typecastLoadField($this->model->getElement($this->field), $value);
                        $this->model->save();

                        return $this->jsSuccess('Update successfully');
                    } catch (ValidationException $e) {
                        $this->app->terminate(json_encode([
                              'success'            => true,
                              'hasValidationError' => true,
                              'atkjs'              => $this->jsError(call_user_func($this->formatErrorMsg, $e, $value))->jsRender(),
                          ]));
                    }
                });
            }
        }

        return $this->model;
    }
1309252
protected function prepareDataProvider($model)
    {
        $dataProvider = parent::prepareDataProvider($model);
        /** @var \yii\db\ActiveQuery $query */
        $query = $dataProvider->query;

        // lazy load related models to mark checkboxes
        $relation = Yii::$app->request->getQueryParam('relation');
        if (!empty($relation)) {
            $query->with($relation);
        }

        return $dataProvider;
    }
296144
public function replaceTags($model)
    {
        if (isset($model->attributes)) {
            foreach ($model->attributes as $key => $attribute) {
                if (in_array($key, $this->dataAttributes)) {
                    $val = Yii::$app->formatter->asDatetime($model->{$key}, 'short');
                } else {
                    $val = $model->{$key};
                }

                $this->subject = str_replace('{' . $key . '}', $val, $this->subject);
                $this->user_subject = str_replace('{' . $key . '}', $val, $this->user_subject);
                $this->text = str_replace('{' . $key . '}', $val, $this->text);
                $this->user_text = str_replace('{' . $key . '}', $val, $this->user_text);
            }
        }

        $table = EmailDetailView::widget([
            'model' => $model,
            'attributes' => $model::$emailAttributes
        ]);

        $this->text = str_replace('{table}', $table, $this->text);
        $this->user_text = str_replace('{table}', $table, $this->user_text);

    }
797403
public function afterSave(Garp_Model_Db $model, $primaryKey) {
        if (is_array($primaryKey)) {
            throw new Exception(self::ERROR_PRIMARY_KEY_CANNOT_BE_ARRAY);
        }

        $boundModel = new Garp_Service_Elasticsearch_Db_BoundModel($model);
        $row = $boundModel->fetchRow($primaryKey);

        if (!$row) {
            /* This is not supposed to happen,
            but due to concurrency it theoretically might. */
            return;
        }

        if (!$this->getRootable()) {
            /* This record should not appear directly in the index,
            *  but only as related records.
            */
            return;
        }

        $rowFilter          = new Garp_Service_Elasticsearch_Db_RowFilter($model);
        $columns            = $this->getColumns();
        $filteredRow        = $rowFilter->filter($row, $columns);

        $elasticModel       = $this->_getElasticModel($model);
        $pkMash             = $this->_mashPrimaryKey($primaryKey);
        $filteredRow['id']  = $pkMash;

        $elasticModel->save($filteredRow);
    }
803786
public function bindGroup(object $model) : object
    {
        parent::bindGroup($model);
        $this->setValue($model);
        return $this;
    }
1189538
protected function _extractDataForLanguage($language, Garp_Model_Db $model) {
        $localizedData = array_filter($this->_queue, 'is_array');
        $out = array();
        foreach ($localizedData as $key => $value) {
            if (array_key_exists($language, $value)) {
                $out[$key] = $value[$language];
            }
        }
        return $out;
    }
850627
public function save(Domain $model): void
    {
        if (!$model->save()) {
            throw new \RuntimeException($this->i18n->t('setrun/sys', 'Saving error'));
        }
    }
564392
private void handleLangs(final Map<String, Object> dataModel) {
        final Locale locale = Latkes.getLocale();
        final String language = locale.getLanguage();
        final String country = locale.getCountry();
        final String variant = locale.getVariant();

        final StringBuilder keyBuilder = new StringBuilder(language);

        if (StringUtils.isNotBlank(country)) {
            keyBuilder.append("_").append(country);
        }
        if (StringUtils.isNotBlank(variant)) {
            keyBuilder.append("_").append(variant);
        }

        final String localKey = keyBuilder.toString();
        final Properties props = langs.get(localKey);

        if (null == props) {
            return;
        }

        final Set<Object> keySet = props.keySet();

        for (final Object key : keySet) {
            dataModel.put((String) key, props.getProperty((String) key));
        }
    }
10165
protected function setForeignAttributesForCreate(Model $model)
	{
		$model->{$this->getPlainForeignKey()} = $this->getParentKey();

		$model->{last(explode('.', $this->morphType))} = $this->morphClass;
	}
417785
public function modelHasLanguage($model, $key)
    {
        if ($this->isLanguage($key)) {
            return true;
        }

        if ($model->translations->get($key)) {
            return true;
        }

        return $this->model->language === $key;
    }
6989
protected function initWidgets($model)
    {
        $config = $model->getFieldConfig();
        $config->model = $model;
        $config->arrayName = class_basename($model);
        $config->context = 'update';

        $widget = $this->makeWidget('Backend\Widgets\Form', $config);
        $widget->bindToController();
        $this->formWidget = $widget;
    }
919865
public function setModel(Model $model)
    {
        if (strpos($this->originalName, '.') !== false) {
            $parts = explode('.', $this->originalName);
            $name = array_pop($parts);

            while ($parts) {
                $part = array_shift($parts);
                $relation = $model->getAttribute($part);

                if ($relation instanceof Model) {
                    $model = $relation;
                    $this->setName($name);
                }
            }
        }

        return parent::setModel($model);
    }
1082161
protected function _afterSave(Garp_Model_Db $model, $pKeys) {
        if (!$this->_queue) {
            return;
        }
        $locales = Garp_I18n::getLocales();
        foreach ($pKeys as $primaryKey) {
            foreach ($locales as $locale) {
                $this->_saveI18nRecord($locale, $model, $primaryKey);
            }
        }
        // Reset queue
        $this->_queue = array();
    }