addBehavior( new SoftDelete([ 'field' => 'deleted', 'value' => 1, ]) ); } public function beforeCreate() { $this->create_time = time(); } public function beforeUpdate() { if ($this->deleted == 1) { $this->published = 0; } $this->update_time = time(); } public function beforeSave() { if (empty($this->icon)) { $this->icon = kg_default_icon_path(); } elseif (Text::startsWith($this->icon, 'http')) { $this->icon = self::getIconPath($this->icon); } } public function afterCreate() { $cache = new MaxTagIdCache(); $cache->rebuild(); } public function afterFetch() { if (!Text::startsWith($this->icon, 'http')) { $this->icon = kg_cos_icon_url($this->icon); } } public static function getIconPath($url) { if (Text::startsWith($url, 'http')) { return parse_url($url, PHP_URL_PATH); } return $url; } }