예제 #1
0
 /**
  * Save plugin file if its a valid file
  *
  * @param file object
  * @return String success/failure message
  */
 public static function saveDriver($file)
 {
     $fileName = $file->getClientOriginalName();
     $destination = app_path() . '/kblis/plugins/';
     try {
         $file->move($destination, $fileName);
     } catch (Exception $e) {
         Log::error($e);
         return trans('messages.unwriteable-destination-folder');
     }
     $className = "\\KBLIS\\Plugins\\" . head(explode(".", last(explode("/", $fileName))));
     // Check if the className is a valid plugin file
     if (class_exists($className)) {
         $dummyIP = "10.10.10.1";
         $instrument = new $className($dummyIP);
         if (is_subclass_of($instrument, '\\KBLIS\\Instrumentation\\AbstractInstrumentor')) {
             $instrument->getEquipmentInfo()['code'];
             return trans('messages.success-importing-driver');
         } else {
             Log::error("invalid-driver-file: " . $className);
         }
     }
     if (File::exists($destination . $fileName)) {
         File::delete($destination . $fileName);
     }
     return trans('messages.invalid-driver-file');
 }
 public function load($envName)
 {
     $cnt = 0;
     $settingsFileName = ".settings-" . $envName;
     $settingsPath = self::$app->environmentPath();
     $settingsFullFileName = $settingsPath . '/' . $settingsFileName;
     if (\File::exists($settingsFullFileName)) {
         $cnt = SettingDotEnv::load($settingsPath, $settingsFileName);
     } else {
         throw new FileNotFoundException($settingsFullFileName);
     }
     return $cnt;
 }