SensorAsset.php in farmOS 2.x
File
modules/core/migrate/src/Plugin/migrate/source/d7/SensorAsset.php
View source
<?php
namespace Drupal\farm_migrate\Plugin\migrate\source\d7;
use Drupal\migrate\Row;
class SensorAsset extends FarmAsset {
public function query() {
$query = parent::query();
$query
->join('farm_sensor', 'fs', 'fa.id = fs.id');
if (isset($this->configuration['sensor_type'])) {
if (!empty($this->configuration['sensor_type'])) {
$query
->condition('fs.type', (array) $this->configuration['sensor_type'], 'IN');
}
else {
$query
->where("fs.type = '' OR fs.type IS NULL");
}
}
$query
->addField('fs', 'type', 'sensor_type');
$query
->addField('fs', 'settings', 'sensor_settings');
return $query;
}
public function prepareRow(Row $row) {
$settings = $row
->getSourceProperty('sensor_settings');
if (!empty($settings)) {
$settings_array = unserialize($settings);
$row
->setSourceProperty('sensor_settings', $settings_array);
}
return parent::prepareRow($row);
}
}