mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 02:07:33 -05:00 
			
		
		
		
	document migration
This commit is contained in:
		
							parent
							
								
									6b0289a3ce
								
							
						
					
					
						commit
						ffec88979e
					
				@ -101,6 +101,8 @@ class Import implements ShouldQueue
 | 
			
		||||
     */
 | 
			
		||||
    private $company;
 | 
			
		||||
 | 
			
		||||
    private $token;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var array
 | 
			
		||||
     */
 | 
			
		||||
@ -229,6 +231,11 @@ class Import implements ShouldQueue
 | 
			
		||||
 | 
			
		||||
    private function processAccount(array $data) :void
 | 
			
		||||
    {
 | 
			
		||||
        if(array_key_exists('token', $data)){
 | 
			
		||||
            $this->token = $data['token'];
 | 
			
		||||
            unset($data['token']);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $account = $this->company->account;
 | 
			
		||||
        $account->fill($data);
 | 
			
		||||
        $account->save();
 | 
			
		||||
@ -966,20 +973,13 @@ class Import implements ShouldQueue
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            $file_url = $resource['url'];
 | 
			
		||||
$file_name = basename($file_url);
 | 
			
		||||
            $file_name = $resource['name'];
 | 
			
		||||
            $file_path = sys_get_temp_dir().'/'.$file_name;
 | 
			
		||||
 | 
			
		||||
file_put_contents($file_path, file_get_contents($file_url), LOCK_EX);
 | 
			
		||||
            file_put_contents($file_path, $this->curlGet($file_url));
 | 
			
		||||
            $finfo = new \finfo(FILEINFO_MIME_TYPE);
 | 
			
		||||
            $file_info = $finfo->file($file_path);
 | 
			
		||||
 | 
			
		||||
nlog($resource['url']);
 | 
			
		||||
nlog($file_url);
 | 
			
		||||
nlog($file_name);
 | 
			
		||||
nlog($file_path);
 | 
			
		||||
nlog($file_info);
 | 
			
		||||
nlog(filesize($file_path));
 | 
			
		||||
 | 
			
		||||
            $uploaded_file = new UploadedFile(
 | 
			
		||||
                            $file_path,
 | 
			
		||||
                            $file_name,
 | 
			
		||||
@ -991,15 +991,8 @@ $uploaded_file = new UploadedFile(
 | 
			
		||||
 | 
			
		||||
            $this->saveDocument($uploaded_file, $entity, $is_public = true);
 | 
			
		||||
 | 
			
		||||
            $uploaded_file = null;
 | 
			
		||||
            $finfo = null;
 | 
			
		||||
            $file_url = null;
 | 
			
		||||
            $file_name = null;
 | 
			
		||||
            $file_path = null;
 | 
			
		||||
            $file_info = null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private function processPaymentTerms(array $data) :void
 | 
			
		||||
@ -1380,4 +1373,27 @@ $uploaded_file = new UploadedFile(
 | 
			
		||||
 | 
			
		||||
        info(print_r($exception->getMessage(), 1));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public function curlGet($url, $headers = false)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        return $this->exec('GET', $url, null);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function exec($method, $url, $data)
 | 
			
		||||
    {
 | 
			
		||||
        nlog($this->token);
 | 
			
		||||
 | 
			
		||||
        $client =  new \GuzzleHttp\Client(['headers' => 
 | 
			
		||||
            [ 
 | 
			
		||||
            'X-Ninja-Token' => $this->token,        
 | 
			
		||||
            ]
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        $response = $client->request('GET', $url);
 | 
			
		||||
 | 
			
		||||
        return $response->getBody();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user