verumconsilium / laravel-browsershot

Browsershot wrapper for Laravel 5
MIT License
111 stars 20 forks source link

make browsershot getter public for more flexibility #22

Closed okaufmann closed 3 years ago

okaufmann commented 4 years ago

I ran into the situation where I need the retrieved HTML as well for a Screenshot request.

When I have something like the following example I can't get the bodyHtml value of browsershot:

$request = Screenshot::loadUrl($url);
$request->windowSize(1920, 1080)
                ->storeAs('public/screenshots', $filename);

$html = $request->bodyHtml();

This is because $this is returned for forwarded calls which is fine for the most cases: https://github.com/verumconsilium/laravel-browsershot/blob/master/src/Wrapper.php#L150

For more flexibility I've made the getter browsershot() public to be able to retrieve the html like this:

$request = Screenshot::loadUrl($url);
$request->windowSize(1920, 1080)
                ->storeAs('public/screenshots', $filename);

$html = $request->browsershot()->bodyHtml();

More calls where the return value of the function called on browsershot is needed are now possible as well.