Esempio n. 1
0
 public function childModels($active = true)
 {
     if ($active) {
         $active = 1;
     } else {
         $active = [0, 1];
     }
     $models = [];
     $models['Sensor'] = Sensor::find()->where(['object_id' => $this->id, 'active' => $active])->all();
     $models['ResourceReference'] = ResourceReference::find()->where(['resource_id' => $this->id, 'active' => $active])->all();
     return $models;
 }
Esempio n. 2
0
 public function childModels($careAboutActive = true)
 {
     if ($careAboutActive) {
         $active = 1;
     } else {
         $active = [0, 1];
     }
     $models = [];
     $models['Resource'] = Resource::find()->where(['object_id' => $this->id, 'active' => $active])->all();
     $models['Sensor'] = Sensor::find()->where(['object_id' => $this->id, 'active' => $active])->all();
     $models['Service'] = Service::find()->where(['id' => $this->service_id, 'active' => $active])->all();
     $models['ResourceReference'] = ResourceReference::find()->where(['object_id' => $this->id, 'active' => $active])->all();
     if ($serviceProvider = Registry::getObject($this->object_id)) {
         if (!$careAboutActive || !empty($serviceProvider->active)) {
             $models['ServiceProvider'] = [$serviceProvider];
         }
     }
     return $models;
 }
Esempio n. 3
0
 public static function getSensorObjectModelClass(\psesd\sensors\base\BaseInterface $object)
 {
     if ($object instanceof SensorInterface) {
         return SensorModel::className();
     }
     if ($object instanceof ServiceInterface) {
         return ServiceModel::className();
     }
     if ($object instanceof ServiceReferenceInterface) {
         return ServiceReferenceModel::className();
     }
     if ($object instanceof ResourceReferenceInterface) {
         return ResourceReferenceModel::className();
     }
     if ($object instanceof ResourceInterface) {
         return ResourceModel::className();
     }
     if ($object instanceof SiteInterface) {
         return SiteModel::className();
     }
     if ($object instanceof ServerInterface) {
         return ServerModel::className();
     }
     if ($object instanceof ProviderInterface) {
         return ProviderModel::className();
     }
     return false;
 }