generated from vormkracht10/laravel-package-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from vormkracht10/feature/route-based-build
Feature/route based build
- Loading branch information
Showing
6 changed files
with
227 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace Vormkracht10\LaravelStatic\Crawler; | ||
|
||
use GuzzleHttp\Exception\RequestException; | ||
use Illuminate\Console\View\Components\Factory as ComponentFactory; | ||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\UriInterface; | ||
use Spatie\Crawler\CrawlObservers\CrawlObserver; | ||
|
||
class StaticCrawlObserver extends CrawlObserver | ||
{ | ||
protected ComponentFactory $components; | ||
|
||
public function __construct(ComponentFactory $components) | ||
{ | ||
$this->components = $components; | ||
} | ||
|
||
/** | ||
* Called when the crawler will crawl the url. | ||
*/ | ||
public function willCrawl(UriInterface $url): void | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Called when the crawler has crawled the given url successfully. | ||
*/ | ||
public function crawled( | ||
UriInterface $url, | ||
ResponseInterface $response, | ||
UriInterface $foundOnUrl = null | ||
): void { | ||
$this->components->info("✔ {$url} has been crawled"); | ||
} | ||
|
||
/** | ||
* Called when the crawler had a problem crawling the given url. | ||
*/ | ||
public function crawlFailed( | ||
UriInterface $url, | ||
RequestException $requestException, | ||
UriInterface $foundOnUrl = null | ||
): void { | ||
$this->components->error("✘ failed to crawl path ({$url})"); | ||
} | ||
|
||
/** | ||
* Called when the crawl has ended. | ||
*/ | ||
public function finishedCrawling(): void | ||
{ | ||
$this->components->info('✔ Static build completed'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.