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.

Contract Capell\AgentDelivery\Contracts\AgentDeliveryAccessPolicyContributor

Section titled “Contract Capell\AgentDelivery\Contracts\AgentDeliveryAccessPolicyContributor”
<?php
declare(strict_types=1);
namespace App\CapellExamples\AgentDelivery;
final class AgentDeliveryAccessPolicyContributorAdapter implements \Capell\AgentDelivery\Contracts\AgentDeliveryAccessPolicyContributor
{
public function __construct(private readonly \Capell\AgentDelivery\Contracts\AgentDeliveryAccessPolicyContributor $backend) {}
#[\Override]
public function allows(\Illuminate\Http\Request $request): bool
{
return $this->backend->allows($request);
}
}
function registerAgentDeliveryAccessPolicyContributorAdapter(\Capell\AgentDelivery\Contracts\AgentDeliveryAccessPolicyContributor $backend): void
{
app()->bind(AgentDeliveryAccessPolicyContributorAdapter::class, static fn (): AgentDeliveryAccessPolicyContributorAdapter => new AgentDeliveryAccessPolicyContributorAdapter($backend));
app()->bind(\Capell\AgentDelivery\Contracts\AgentDeliveryAccessPolicyContributor::class, AgentDeliveryAccessPolicyContributorAdapter::class);
app()->tag([AgentDeliveryAccessPolicyContributorAdapter::class], \Capell\AgentDelivery\Contracts\AgentDeliveryAccessPolicyContributor::TAG);
}

Contract Capell\AgentDelivery\Contracts\AgentDeliveryChunkContributor

Section titled “Contract Capell\AgentDelivery\Contracts\AgentDeliveryChunkContributor”
<?php
declare(strict_types=1);
namespace App\CapellExamples\AgentDelivery;
final class AgentDeliveryChunkContributorAdapter implements \Capell\AgentDelivery\Contracts\AgentDeliveryChunkContributor
{
public function __construct(private readonly \Capell\AgentDelivery\Contracts\AgentDeliveryChunkContributor $backend) {}
#[\Override]
public function chunks(\Capell\Core\Contracts\Pageable $page, \Capell\Core\Models\Site $site, \Capell\Core\Models\Language $language): array
{
return $this->backend->chunks($page, $site, $language);
}
}
function registerAgentDeliveryChunkContributorAdapter(\Capell\AgentDelivery\Contracts\AgentDeliveryChunkContributor $backend): void
{
app()->bind(AgentDeliveryChunkContributorAdapter::class, static fn (): AgentDeliveryChunkContributorAdapter => new AgentDeliveryChunkContributorAdapter($backend));
app()->bind(\Capell\AgentDelivery\Contracts\AgentDeliveryChunkContributor::class, AgentDeliveryChunkContributorAdapter::class);
app()->tag([AgentDeliveryChunkContributorAdapter::class], \Capell\AgentDelivery\Contracts\AgentDeliveryChunkContributor::TAG);
}

Contract Capell\AgentDelivery\Contracts\AgentDeliveryContributor

Section titled “Contract Capell\AgentDelivery\Contracts\AgentDeliveryContributor”
<?php
declare(strict_types=1);
namespace App\CapellExamples\AgentDelivery;
final class AgentDeliveryContributorAdapter implements \Capell\AgentDelivery\Contracts\AgentDeliveryContributor
{
public function __construct(private readonly \Capell\AgentDelivery\Contracts\AgentDeliveryContributor $backend) {}
#[\Override]
public function chunks(\Capell\Core\Contracts\Pageable $page, \Capell\Core\Models\Site $site, \Capell\Core\Models\Language $language): array
{
return $this->backend->chunks($page, $site, $language);
}
#[\Override]
public function metadata(\Capell\Core\Contracts\Pageable $page, \Capell\Core\Models\Site $site, \Capell\Core\Models\Language $language): array
{
return $this->backend->metadata($page, $site, $language);
}
}
function registerAgentDeliveryContributorAdapter(\Capell\AgentDelivery\Contracts\AgentDeliveryContributor $backend): void
{
app()->bind(AgentDeliveryContributorAdapter::class, static fn (): AgentDeliveryContributorAdapter => new AgentDeliveryContributorAdapter($backend));
app()->bind(\Capell\AgentDelivery\Contracts\AgentDeliveryContributor::class, AgentDeliveryContributorAdapter::class);
app()->tag([AgentDeliveryContributorAdapter::class], \Capell\AgentDelivery\Contracts\AgentDeliveryContributor::TAG);
}

Contract Capell\AgentDelivery\Contracts\AgentDeliveryMetadataContributor

Section titled “Contract Capell\AgentDelivery\Contracts\AgentDeliveryMetadataContributor”
<?php
declare(strict_types=1);
namespace App\CapellExamples\AgentDelivery;
final class AgentDeliveryMetadataContributorAdapter implements \Capell\AgentDelivery\Contracts\AgentDeliveryMetadataContributor
{
public function __construct(private readonly \Capell\AgentDelivery\Contracts\AgentDeliveryMetadataContributor $backend) {}
#[\Override]
public function metadata(\Capell\Core\Contracts\Pageable $page, \Capell\Core\Models\Site $site, \Capell\Core\Models\Language $language): array
{
return $this->backend->metadata($page, $site, $language);
}
}
function registerAgentDeliveryMetadataContributorAdapter(\Capell\AgentDelivery\Contracts\AgentDeliveryMetadataContributor $backend): void
{
app()->bind(AgentDeliveryMetadataContributorAdapter::class, static fn (): AgentDeliveryMetadataContributorAdapter => new AgentDeliveryMetadataContributorAdapter($backend));
app()->bind(\Capell\AgentDelivery\Contracts\AgentDeliveryMetadataContributor::class, AgentDeliveryMetadataContributorAdapter::class);
app()->tag([AgentDeliveryMetadataContributorAdapter::class], \Capell\AgentDelivery\Contracts\AgentDeliveryMetadataContributor::TAG);
}

Contract Capell\AgentDelivery\Contracts\AgentDeliveryReferenceContributor

Section titled “Contract Capell\AgentDelivery\Contracts\AgentDeliveryReferenceContributor”
<?php
declare(strict_types=1);
namespace App\CapellExamples\AgentDelivery;
final class AgentDeliveryReferenceContributorAdapter implements \Capell\AgentDelivery\Contracts\AgentDeliveryReferenceContributor
{
public function __construct(private readonly \Capell\AgentDelivery\Contracts\AgentDeliveryReferenceContributor $backend) {}
#[\Override]
public function references(\Capell\Core\Contracts\Pageable $page, \Capell\Core\Models\Site $site, \Capell\Core\Models\Language $language): array
{
return $this->backend->references($page, $site, $language);
}
}
function registerAgentDeliveryReferenceContributorAdapter(\Capell\AgentDelivery\Contracts\AgentDeliveryReferenceContributor $backend): void
{
app()->bind(AgentDeliveryReferenceContributorAdapter::class, static fn (): AgentDeliveryReferenceContributorAdapter => new AgentDeliveryReferenceContributorAdapter($backend));
app()->bind(\Capell\AgentDelivery\Contracts\AgentDeliveryReferenceContributor::class, AgentDeliveryReferenceContributorAdapter::class);
app()->tag([AgentDeliveryReferenceContributorAdapter::class], \Capell\AgentDelivery\Contracts\AgentDeliveryReferenceContributor::TAG);
}

Contract Capell\AgentDelivery\Contracts\AgentDeliveryRelatedUrlContributor

Section titled “Contract Capell\AgentDelivery\Contracts\AgentDeliveryRelatedUrlContributor”
<?php
declare(strict_types=1);
namespace App\CapellExamples\AgentDelivery;
final class AgentDeliveryRelatedUrlContributorAdapter implements \Capell\AgentDelivery\Contracts\AgentDeliveryRelatedUrlContributor
{
public function __construct(private readonly \Capell\AgentDelivery\Contracts\AgentDeliveryRelatedUrlContributor $backend) {}
#[\Override]
public function relatedUrls(\Capell\Core\Contracts\Pageable $page, \Capell\Core\Models\Site $site, \Capell\Core\Models\Language $language): array
{
return $this->backend->relatedUrls($page, $site, $language);
}
}
function registerAgentDeliveryRelatedUrlContributorAdapter(\Capell\AgentDelivery\Contracts\AgentDeliveryRelatedUrlContributor $backend): void
{
app()->bind(AgentDeliveryRelatedUrlContributorAdapter::class, static fn (): AgentDeliveryRelatedUrlContributorAdapter => new AgentDeliveryRelatedUrlContributorAdapter($backend));
app()->bind(\Capell\AgentDelivery\Contracts\AgentDeliveryRelatedUrlContributor::class, AgentDeliveryRelatedUrlContributorAdapter::class);
app()->tag([AgentDeliveryRelatedUrlContributorAdapter::class], \Capell\AgentDelivery\Contracts\AgentDeliveryRelatedUrlContributor::TAG);
}