public function editItem() { /** @var ActiveRecord $owner */ $owner = $this->owner; if ($this->multiLanguage) { $map = SiteMap::findOne(['model_name' => $owner, 'model_id' => $owner->getPrimaryKey(), 'lang_id' => 0]); if (!$map) { $map = new SiteMap(); $map->model_name = $owner::className(); $map->model_id = $owner->getPrimaryKey(); $map->lang_id = 0; } if ($owner->hasAttribute($this->attribute)) { $map->label = $owner->getAttribute($this->attribute); } $map->route = $this->route; $map->params = jd($this->params); $map->changefreq = $this->freq; $map->priority = $this->priority; $map->updated = time(); $map->save(); } else { foreach ($this->languages as $language) { $map = SiteMap::findOne(['model_name' => $owner, 'model_id' => $owner->getPrimaryKey(), 'lang_id' => $language]); if (!$map) { $map = new SiteMap(); $map->model_name = $owner::className(); $map->model_id = $owner->getPrimaryKey(); $map->lang_id = $language; } if ($owner->hasAttribute($this->attribute . '_' . $language)) { $map->label = $owner->getAttribute($this->attribute . '_' . $language); } $map->route = $this->route; if ($language == $this->defaultLanguage) { $map->params = jd($this->params); } else { $map->params = jd([$this->languageVar => $language], $this->params); } $map->changefreq = $this->freq; $map->priority = $this->priority; $map->updated = time(); $map->save(); } } }