Skip to content

Worked extension examples

These developer-facing recipes are kept beside the package contract. Replace the example values with the site-specific records and data objects used by the calling workflow.

<?php
declare(strict_types=1);
final class ExampleDiscoverableUrlSourceImplementation implements \Capell\SiteDiscovery\Contracts\DiscoverableUrlSource
{
/**
* @return Collection<int, DiscoverableUrlData>
*/
public function discover(\Capell\Core\Models\Site $site, \Capell\Core\Models\Language $language, ?\Capell\Core\Models\SiteDomain $domain = null): \Illuminate\Support\Collection
{
throw new LogicException('Implement this package contract for the calling site.');
}
}
app()->bind(\Capell\SiteDiscovery\Contracts\DiscoverableUrlSource::class, ExampleDiscoverableUrlSourceImplementation::class);
<?php
declare(strict_types=1);
final class ExampleDiscoveryOutputSourceImplementation implements \Capell\SiteDiscovery\Contracts\DiscoveryOutputSource
{
/**
* @return Collection<int, DiscoveryOutputData>
*/
public function discover(\Capell\Core\Models\Site $site, \Capell\Core\Models\Language $language, ?\Capell\Core\Models\SiteDomain $domain = null): \Illuminate\Support\Collection
{
throw new LogicException('Implement this package contract for the calling site.');
}
}
app()->bind(\Capell\SiteDiscovery\Contracts\DiscoveryOutputSource::class, ExampleDiscoveryOutputSourceImplementation::class);
<?php
declare(strict_types=1);
final class ExampleGeneratedOutputCoverageSourceImplementation implements \Capell\SiteDiscovery\Contracts\GeneratedOutputCoverageSource
{
public function key(): string
{
throw new LogicException('Implement this package contract for the calling site.');
}
/**
* @param Collection<int, PublicUrlRegistryEntryData> $registryEntries
* @return Collection<int, string>
*/
public function coveredUrls(\Illuminate\Support\Collection $registryEntries): \Illuminate\Support\Collection
{
throw new LogicException('Implement this package contract for the calling site.');
}
}
app()->bind(\Capell\SiteDiscovery\Contracts\GeneratedOutputCoverageSource::class, ExampleGeneratedOutputCoverageSourceImplementation::class);
<?php
declare(strict_types=1);
final class ExamplePublicUrlContributorImplementation implements \Capell\SiteDiscovery\Contracts\PublicUrlContributor
{
public function __construct()
{
return;
}
}
app()->bind(\Capell\SiteDiscovery\Contracts\PublicUrlContributor::class, ExamplePublicUrlContributorImplementation::class);
<?php
declare(strict_types=1);
final class ExampleSitemapableImplementation implements \Capell\SiteDiscovery\Contracts\Sitemapable
{
/**
* @return Collection<array-key, mixed>
*/
public function fetch(): \Illuminate\Support\Collection
{
throw new LogicException('Implement this package contract for the calling site.');
}
}
app()->bind(\Capell\SiteDiscovery\Contracts\Sitemapable::class, ExampleSitemapableImplementation::class);
<?php
declare(strict_types=1);
final class ExampleUrlChangeNotifierImplementation implements \Capell\SiteDiscovery\Contracts\UrlChangeNotifier
{
/**
* @param Collection<int, non-falsy-string> $urls
*/
public function notify(\Capell\Core\Models\Site $site, \Capell\Core\Models\Language $language, \Illuminate\Support\Collection $urls, ?\Capell\Core\Models\SiteDomain $domain = null): \Capell\SiteDiscovery\Data\UrlChangeNotificationResultData
{
throw new LogicException('Implement this package contract for the calling site.');
}
}
app()->bind(\Capell\SiteDiscovery\Contracts\UrlChangeNotifier::class, ExampleUrlChangeNotifierImplementation::class);
<?php
declare(strict_types=1);
$inputs = []; // Supply the arguments required by the action handle() method.
resolve(\Capell\SiteDiscovery\Actions\BuildGeneratedOutputParityReportAction::class)->handle(...$inputs);
<?php
declare(strict_types=1);
$inputs = []; // Supply the arguments required by the action handle() method.
resolve(\Capell\SiteDiscovery\Actions\BuildPublicUrlRegistryAction::class)->handle(...$inputs);
<?php
declare(strict_types=1);
$inputs = []; // Supply the arguments required by the action handle() method.
resolve(\Capell\SiteDiscovery\Actions\BuildPublicUrlRepairQueueAction::class)->handle(...$inputs);
<?php
declare(strict_types=1);
$inputs = []; // Supply the arguments required by the action handle() method.
resolve(\Capell\SiteDiscovery\Actions\GenerateSitemapAction::class)->handle(...$inputs);
<?php
declare(strict_types=1);
$inputs = []; // Supply the arguments required by the action handle() method.
resolve(\Capell\SiteDiscovery\Actions\SetupSiteDiscoveryPackageAction::class)->handle(...$inputs);
<?php
declare(strict_types=1);
$inputs = []; // Supply the arguments required by the action handle() method.
resolve(\Capell\SiteDiscovery\Actions\ValidateSitemapQualityAction::class)->handle(...$inputs);