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 ExampleSearchImplementation implements \Capell\Search\Contracts\Search
{
/**
* @return LengthAwarePaginator<int, SearchResultData>
*/
public function search(string $query, int $perPage = 10, int $page = 1, ?int $siteId = null, ?int $languageId = null, ?\Capell\Search\Data\SearchFilterData $filters = null): \Illuminate\Contracts\Pagination\LengthAwarePaginator
{
throw new LogicException('Implement this package contract for the calling site.');
}
/**
* Return public-safe HTML for highlighted search text.
*
* Implementations must escape the full input text and only add trusted
* highlight markup, currently `<mark>...</mark>`.
*/
public function highlight(string $text, string $query): string
{
throw new LogicException('Implement this package contract for the calling site.');
}
}
app()->bind(\Capell\Search\Contracts\Search::class, ExampleSearchImplementation::class);
<?php
declare(strict_types=1);
$inputs = []; // Supply the arguments required by the action handle() method.
resolve(\Capell\Search\Actions\ApplySearchResultEnhancementsAction::class)->handle(...$inputs);
<?php
declare(strict_types=1);
$inputs = []; // Supply the arguments required by the action handle() method.
resolve(\Capell\Search\Actions\BuildTopClickedResultsQueryAction::class)->handle(...$inputs);
<?php
declare(strict_types=1);
$inputs = []; // Supply the arguments required by the action handle() method.
resolve(\Capell\Search\Actions\BuildTopSearchesQueryAction::class)->handle(...$inputs);
<?php
declare(strict_types=1);
$inputs = []; // Supply the arguments required by the action handle() method.
resolve(\Capell\Search\Actions\BuildTrendingSearchesQueryAction::class)->handle(...$inputs);
<?php
declare(strict_types=1);
$inputs = []; // Supply the arguments required by the action handle() method.
resolve(\Capell\Search\Actions\BuildZeroResultSearchesQueryAction::class)->handle(...$inputs);
<?php
declare(strict_types=1);
$inputs = []; // Supply the arguments required by the action handle() method.
resolve(\Capell\Search\Actions\CreatePromotedResultFromZeroResultSearchAction::class)->handle(...$inputs);
<?php
declare(strict_types=1);
$inputs = []; // Supply the arguments required by the action handle() method.
resolve(\Capell\Search\Actions\CreateSynonymFromZeroResultSearchAction::class)->handle(...$inputs);
<?php
declare(strict_types=1);
$inputs = []; // Supply the arguments required by the action handle() method.
resolve(\Capell\Search\Actions\FlushScoutSearchSourcesAction::class)->handle(...$inputs);
<?php
declare(strict_types=1);
$inputs = []; // Supply the arguments required by the action handle() method.
resolve(\Capell\Search\Actions\IndexScoutSearchSourcesAction::class)->handle(...$inputs);
<?php
declare(strict_types=1);
$inputs = []; // Supply the arguments required by the action handle() method.
resolve(\Capell\Search\Actions\InstallSearchPackageAction::class)->handle(...$inputs);
<?php
declare(strict_types=1);
$inputs = []; // Supply the arguments required by the action handle() method.
resolve(\Capell\Search\Actions\NormalizeSearchQueryAction::class)->handle(...$inputs);
<?php
declare(strict_types=1);
$inputs = []; // Supply the arguments required by the action handle() method.
resolve(\Capell\Search\Actions\PurgeSearchLogsAction::class)->handle(...$inputs);
<?php
declare(strict_types=1);
$inputs = []; // Supply the arguments required by the action handle() method.
resolve(\Capell\Search\Actions\RecordSearchAction::class)->handle(...$inputs);
<?php
declare(strict_types=1);
$inputs = []; // Supply the arguments required by the action handle() method.
resolve(\Capell\Search\Actions\RecordSearchResultClickAction::class)->handle(...$inputs);
<?php
declare(strict_types=1);
$inputs = []; // Supply the arguments required by the action handle() method.
resolve(\Capell\Search\Actions\ResolveExpandedSearchQueriesAction::class)->handle(...$inputs);
<?php
declare(strict_types=1);
$inputs = []; // Supply the arguments required by the action handle() method.
resolve(\Capell\Search\Actions\ResolvePromotedSearchResultsAction::class)->handle(...$inputs);
<?php
declare(strict_types=1);
$inputs = []; // Supply the arguments required by the action handle() method.
resolve(\Capell\Search\Actions\RunSearchAction::class)->handle(...$inputs);