Files
futurewalker/app/Helpers/FirstParty/SitemapCrawler/CustomCrawlProfile.php
2023-12-03 11:20:03 +08:00

27 lines
542 B
PHP

<?php
namespace App\Helpers\FirstParty\SitemapCrawler;
use Psr\Http\Message\UriInterface;
use Spatie\Crawler\CrawlProfiles\CrawlProfile;
class CustomCrawlProfile extends CrawlProfile
{
/** @var callable */
protected $callback;
public function shouldCrawlCallback(callable $callback): void
{
$this->callback = $callback;
}
public function shouldCrawl(UriInterface $url): bool
{
if ($url->getQuery() !== '') {
return false;
}
return ($this->callback)($url);
}
}