/** * @param bool $insert * @return bool */ public function beforeSave($insert) { $constWrappers = self::COLUMN_BEFORE_SAVE; foreach (static::formats() as $column => $format) { if (!empty($constWrappers[$format]) && is_callable($constWrappers[$format])) { $saved = $this->getAttribute($column); if ($saved) { $this->_saved[$column] = $saved; $this->setAttribute($column, call_user_func($constWrappers[$format], $saved)); } } } return parent::beforeSave($insert); }
protected function allColumns() { /** @var ActiveRecord $modelClass */ $modelClass = $this->modelClass; $schema = $modelClass::getTableSchema(); foreach ($schema->columns as $column) { if (ActiveRecord::isSpatial($column)) { $field = $column->name; $this->addSelect(["AsText({$field}) AS {$field}"]); } } }