mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-03 23:17:32 -05:00 
			
		
		
		
	Polish for Phantom JS implementation
This commit is contained in:
		
							parent
							
								
									d7dbde3789
								
							
						
					
					
						commit
						8b9c83da1e
					
				@ -55,24 +55,13 @@ class Phantom
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $file_path = $path . $entity_obj->number . '.pdf';
 | 
					        $file_path = $path . $entity_obj->number . '.pdf';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		$url = rtrim(config('ninja.app_url'), "/") . 'phantom/' . $entity . '/' . $invitation . '?phantomjs_secret='. config('ninja.phantomjs_secret');
 | 
							$url = config('ninja.app_url') . 'phantom/' . $entity . '/' . $invitation->key . '?phantomjs_secret='. config('ninja.phantomjs_secret');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		$json_payload = new \stdClass;
 | 
							$key = config('ninja.phantomjs_key');
 | 
				
			||||||
		$json_payload->url = $url;
 | 
							$secret = config('ninja.phantomjs_key');
 | 
				
			||||||
		$json_payload->renderType = "pdf";
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		$url = "http://PhantomJScloud.com/api/browser/v2/" . config('ninja.phantomjs_key');
 | 
							$phantom_url = "https://phantomjscloud.com/api/browser/v2/{$key}/?request=%7Burl:%22{$url}%22,renderType:%22pdf%22%7D";
 | 
				
			||||||
		$payload = json_encode($json_payload);
 | 
					        $pdf = \App\Utils\CurlUtils::get($phantom_url);
 | 
				
			||||||
		$options = array(
 | 
					 | 
				
			||||||
		    'http' => array(
 | 
					 | 
				
			||||||
		        'header'  => "Content-type: application/json\r\n",
 | 
					 | 
				
			||||||
		        'method'  => 'POST',
 | 
					 | 
				
			||||||
		        'content' => $payload
 | 
					 | 
				
			||||||
		    )
 | 
					 | 
				
			||||||
		);
 | 
					 | 
				
			||||||
		$context  = stream_context_create($options);
 | 
					 | 
				
			||||||
		$pdf = file_get_contents($url, false, $context);
 | 
					 | 
				
			||||||
		if ($pdf === FALSE) { /* Handle error */ info("i did not make the PDF from phantom"); }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Storage::makeDirectory($path, 0755);
 | 
					        Storage::makeDirectory($path, 0755);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -80,7 +69,6 @@ class Phantom
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        return $file_path;
 | 
					        return $file_path;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public function displayInvitation(string $entity, string $invitation_key)
 | 
						public function displayInvitation(string $entity, string $invitation_key)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user