public function SensorAsset::query in farmOS 2.x
Return value
\Drupal\Core\Database\Query\SelectInterface
Overrides Asset::query
File
- modules/
core/ migrate/ src/ Plugin/ migrate/ source/ d7/ SensorAsset.php, line 23
Class
- SensorAsset
- Migration source for the d7 sensor asset.
Namespace
Drupal\farm_migrate\Plugin\migrate\source\d7Code
public function query() {
// Get the parent query.
$query = parent::query();
// Join in the farm_sensor table.
$query
->join('farm_sensor', 'fs', 'fa.id = fs.id');
// Limit by the sensor type.
if (isset($this->configuration['sensor_type'])) {
// Specify the 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");
}
}
// Add sensor fields aliased with correct name.
$query
->addField('fs', 'type', 'sensor_type');
$query
->addField('fs', 'settings', 'sensor_settings');
return $query;
}