32 lines
646 B
PHP
32 lines
646 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
class BlockSubwayBuilder implements ModelBuilder
|
||
|
|
{
|
||
|
|
|
||
|
|
public function getModelClassName()
|
||
|
|
{
|
||
|
|
return BlockSubway::className();
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @param array $data
|
||
|
|
* @return ImportRecord
|
||
|
|
*/
|
||
|
|
public function getModel(array $data)
|
||
|
|
{
|
||
|
|
assert('!empty($data)');
|
||
|
|
assert('!empty($data["blockid"])');
|
||
|
|
assert('!empty($data["subwayid"])');
|
||
|
|
|
||
|
|
$model = BlockSubway::findByBlockAndSubway((int)$data['blockid'], (int)$data['subwayid']);
|
||
|
|
if (!$model) {
|
||
|
|
$model = new BlockSubway;
|
||
|
|
}
|
||
|
|
|
||
|
|
$model->block_id = (int)$data['blockid'];
|
||
|
|
$model->subway_id = (int)$data['subwayid'];
|
||
|
|
$model->distance = $data['distance'];
|
||
|
|
|
||
|
|
return $model;
|
||
|
|
}
|
||
|
|
}
|