Skip to content

Extension and action examples

Use the action functions with records and Data objects supplied by your application. They pass each argument to the package operation and return its result.

These adapters show container registration. Use the owning package registry when a contract requires contributor discovery.

Contract adapters wrap an existing implementation. Call their registration function from your service provider with that implementation; tagged contracts keep their declared tag. Resolve the backend by its concrete class before registration so the replacement contract does not resolve itself. Static contract metadata uses one backend class per adapter.

<?php
declare(strict_types=1);
namespace App\CapellExamples\KnowledgeBase;
function runBuildAiReadableKnowledgeBaseOutput(): \Illuminate\Support\Collection
{
return \Capell\KnowledgeBase\Actions\BuildAiReadableKnowledgeBaseOutputAction::run();
}
<?php
declare(strict_types=1);
namespace App\CapellExamples\KnowledgeBase;
function runBuildKnowledgeBaseArticleSchema(\Capell\KnowledgeBase\Models\KnowledgeBaseArticle $article, ?string $canonicalUrl = null): ?array
{
return \Capell\KnowledgeBase\Actions\BuildKnowledgeBaseArticleSchemaAction::run($article, $canonicalUrl);
}
<?php
declare(strict_types=1);
namespace App\CapellExamples\KnowledgeBase;
function runBuildKnowledgeBaseSearchDocuments(): \Illuminate\Support\Collection
{
return \Capell\KnowledgeBase\Actions\BuildKnowledgeBaseSearchDocumentsAction::run();
}

Action buildPublicKnowledgeBaseArticleData

Section titled “Action buildPublicKnowledgeBaseArticleData”
<?php
declare(strict_types=1);
namespace App\CapellExamples\KnowledgeBase;
function runBuildPublicKnowledgeBaseArticleData(\Capell\KnowledgeBase\Models\KnowledgeBaseArticle $article): ?\Capell\KnowledgeBase\Data\PublicKnowledgeBaseArticleData
{
return \Capell\KnowledgeBase\Actions\BuildPublicKnowledgeBaseArticleDataAction::run($article);
}
<?php
declare(strict_types=1);
namespace App\CapellExamples\KnowledgeBase;
function runBuildPublicKnowledgeBaseNavigation(): \Illuminate\Support\Collection
{
return \Capell\KnowledgeBase\Actions\BuildPublicKnowledgeBaseNavigationAction::run();
}
<?php
declare(strict_types=1);
namespace App\CapellExamples\KnowledgeBase;
function runCreateKnowledgeBaseArticle(\Capell\KnowledgeBase\Data\CreateKnowledgeBaseArticleData $data): \Capell\KnowledgeBase\Models\KnowledgeBaseArticle
{
return \Capell\KnowledgeBase\Actions\CreateKnowledgeBaseArticleAction::run($data);
}
<?php
declare(strict_types=1);
namespace App\CapellExamples\KnowledgeBase;
function runCreateKnowledgeBaseArticleVersion(\Capell\KnowledgeBase\Data\CreateKnowledgeBaseArticleVersionData $data): \Capell\KnowledgeBase\Models\KnowledgeBaseArticleVersion
{
return \Capell\KnowledgeBase\Actions\CreateKnowledgeBaseArticleVersionAction::run($data);
}
<?php
declare(strict_types=1);
namespace App\CapellExamples\KnowledgeBase;
function runPruneKnowledgeBaseHistory(?int $retentionDays = null, ?int $versionsPerArticle = null): int
{
return \Capell\KnowledgeBase\Actions\PruneKnowledgeBaseHistoryAction::run($retentionDays, $versionsPerArticle);
}
<?php
declare(strict_types=1);
namespace App\CapellExamples\KnowledgeBase;
function runPublishKnowledgeBaseArticleVersion(\Capell\KnowledgeBase\Models\KnowledgeBaseArticleVersion $version): \Capell\KnowledgeBase\Models\KnowledgeBaseArticle
{
return \Capell\KnowledgeBase\Actions\PublishKnowledgeBaseArticleVersionAction::run($version);
}
<?php
declare(strict_types=1);
namespace App\CapellExamples\KnowledgeBase;
function runRecordKnowledgeBaseArticleFeedback(\Capell\KnowledgeBase\Data\RecordKnowledgeBaseArticleFeedbackData $data): \Capell\KnowledgeBase\Models\KnowledgeBaseArticleFeedback
{
return \Capell\KnowledgeBase\Actions\RecordKnowledgeBaseArticleFeedbackAction::run($data);
}
<?php
declare(strict_types=1);
namespace App\CapellExamples\KnowledgeBase;
function runRelateKnowledgeBaseArticles(\Capell\KnowledgeBase\Models\KnowledgeBaseArticle $article, \Capell\KnowledgeBase\Models\KnowledgeBaseArticle $relatedArticle, \Capell\KnowledgeBase\Enums\KnowledgeBaseRelatedArticleType $relationType = \Capell\KnowledgeBase\Enums\KnowledgeBaseRelatedArticleType::Related, int $sortOrder = 0): \Capell\KnowledgeBase\Models\KnowledgeBaseRelatedArticle
{
return \Capell\KnowledgeBase\Actions\RelateKnowledgeBaseArticlesAction::run($article, $relatedArticle, $relationType, $sortOrder);
}
<?php
declare(strict_types=1);
namespace App\CapellExamples\KnowledgeBase;
function runSeedKnowledgeBaseDemo(\Capell\KnowledgeBase\Data\SeedKnowledgeBaseDemoData $data): void
{
\Capell\KnowledgeBase\Actions\SeedKnowledgeBaseDemoAction::run($data);
}