Exemplo n.º 1
0
 public static function build($id = 0, $resource)
 {
     if ($id) {
         $resource->setId($id);
         if (!parent::loadByID($resource)) {
             throw new \Exception('Resource id not found:' . $id);
         }
     }
     return $resource;
 }
Exemplo n.º 2
0
 public static function deleteDevice($device_id, $specific_device_id, $device_type_id)
 {
     $systems_device = new Resource();
     $systems_device->setId($device_id);
     if (!parent::loadByID($systems_device)) {
         throw new \Exception('Cannot load resource. System id not found:' . $device_id);
     }
     switch ($device_type_id) {
         case '1':
         case '2':
             $specific_device = new PCResource();
             break;
         case '3':
             $specific_device = new IPADResource();
             break;
         case '4':
             $specific_device = new PrinterResource();
             break;
         case '5':
             $specific_device = new CameraResource();
             break;
         case '6':
             $specific_device = new DigitalSignResource();
             break;
     }
     $specific_device->setId($specific_device_id);
     if (!parent::loadByID($specific_device)) {
         throw new \Exception('Cannot load specific resource. System id not found:' . $specific_device_id);
     }
     if (!SystemDevice::deleteResource($specific_device)) {
         throw new \Exception('Cannot delete specific resource. Query failed');
     }
     if (!SystemDevice::deleteResource($systems_device)) {
         throw new \Exception('Cannot delete resource. Query failed');
     }
 }