28 lines
498 B
PHP
28 lines
498 B
PHP
<?php
|
|
|
|
class RegionBuilder implements ModelBuilder
|
|
{
|
|
|
|
public function getModelClassName()
|
|
{
|
|
return Region::className();
|
|
}
|
|
|
|
/**
|
|
* @param array $data
|
|
* @return ImportRecord
|
|
*/
|
|
public function getModel(array $data)
|
|
{
|
|
assert('!empty($data)');
|
|
assert('!empty($data["id"])');
|
|
$id = (int)$data['id'];
|
|
$model = Region::findOne($id) ?: new Region;
|
|
|
|
$model->id = $id;
|
|
$model->name = $data['name'];
|
|
$model->is_city_region = (int)$data['iscityregion'];
|
|
|
|
return $model;
|
|
}
|
|
} |