# Extension and action examples

<!-- Maintained by scripts/generate-package-readmes.php -->

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.

## Action `anonymizePrivacySubject`

<!-- example: action anonymizePrivacySubject -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\PrivacyCenter;

function runAnonymizePrivacySubject(\Illuminate\Database\Eloquent\Model $subject): int
{
    return \Capell\PrivacyCenter\Actions\AnonymizePrivacySubjectAction::run($subject);
}
```

## Action `applyRetentionRule`

<!-- example: action applyRetentionRule -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\PrivacyCenter;

function runApplyRetentionRule(\Capell\PrivacyCenter\Models\RetentionRule $rule, ?\Carbon\CarbonInterface $now = null, bool $dryRun = false): \Capell\PrivacyCenter\Data\RetentionExecutionResultData
{
    return \Capell\PrivacyCenter\Actions\ApplyRetentionRuleAction::run($rule, $now, $dryRun);
}
```

## Action `applyRetentionRules`

<!-- example: action applyRetentionRules -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\PrivacyCenter;

function runApplyRetentionRules(?\Carbon\CarbonInterface $now = null): \Illuminate\Support\Collection
{
    return \Capell\PrivacyCenter\Actions\ApplyRetentionRulesAction::run($now);
}
```

## Action `buildPrivacyCenterOverviewStats`

<!-- example: action buildPrivacyCenterOverviewStats -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\PrivacyCenter;

function runBuildPrivacyCenterOverviewStats(): array
{
    return \Capell\PrivacyCenter\Actions\BuildPrivacyCenterOverviewStatsAction::run();
}
```

## Action `buildPrivacyExport`

<!-- example: action buildPrivacyExport -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\PrivacyCenter;

function runBuildPrivacyExport(\Illuminate\Database\Eloquent\Model $subject): \Capell\PrivacyCenter\Data\PrivacyExportData
{
    return \Capell\PrivacyCenter\Actions\BuildPrivacyExportAction::run($subject);
}
```

## Action `createRetentionRule`

<!-- example: action createRetentionRule -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\PrivacyCenter;

function runCreateRetentionRule(\Capell\PrivacyCenter\Data\RetentionRuleData $ruleData): \Capell\PrivacyCenter\Models\RetentionRule
{
    return \Capell\PrivacyCenter\Actions\CreateRetentionRuleAction::run($ruleData);
}
```

## Action `markPrivacyRequestFulfilled`

<!-- example: action markPrivacyRequestFulfilled -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\PrivacyCenter;

function runMarkPrivacyRequestFulfilled(\Capell\PrivacyCenter\Models\PrivacyRequest $privacyRequest, array $workflowPayload = [], ?\Carbon\CarbonInterface $fulfilledAt = null): \Capell\PrivacyCenter\Models\PrivacyRequest
{
    return \Capell\PrivacyCenter\Actions\MarkPrivacyRequestFulfilledAction::run($privacyRequest, $workflowPayload, $fulfilledAt);
}
```

## Action `openPrivacyRequest`

<!-- example: action openPrivacyRequest -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\PrivacyCenter;

function runOpenPrivacyRequest(\Capell\PrivacyCenter\Data\PrivacyRequestData $requestData, ?\Illuminate\Database\Eloquent\Model $requester = null, ?\Illuminate\Database\Eloquent\Model $subject = null): \Capell\PrivacyCenter\Models\PrivacyRequest
{
    return \Capell\PrivacyCenter\Actions\OpenPrivacyRequestAction::run($requestData, $requester, $subject);
}
```

## Action `recordConsent`

<!-- example: action recordConsent -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\PrivacyCenter;

function runRecordConsent(\Capell\PrivacyCenter\Data\ConsentRecordData $consentData, ?\Illuminate\Database\Eloquent\Model $subject = null, ?\Illuminate\Database\Eloquent\Model $source = null): \Capell\PrivacyCenter\Models\ConsentRecord
{
    return \Capell\PrivacyCenter\Actions\RecordConsentAction::run($consentData, $subject, $source);
}
```

## Action `recordPolicyAcceptance`

<!-- example: action recordPolicyAcceptance -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\PrivacyCenter;

function runRecordPolicyAcceptance(\Capell\PrivacyCenter\Data\PolicyAcceptanceData $acceptanceData, ?\Illuminate\Database\Eloquent\Model $subject = null): \Capell\PrivacyCenter\Models\PolicyAcceptance
{
    return \Capell\PrivacyCenter\Actions\RecordPolicyAcceptanceAction::run($acceptanceData, $subject);
}
```

## Action `registerConsentPolicy`

<!-- example: action registerConsentPolicy -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\PrivacyCenter;

function runRegisterConsentPolicy(\Capell\PrivacyCenter\Data\ConsentPolicyData $policyData): \Capell\PrivacyCenter\Models\ConsentPolicy
{
    return \Capell\PrivacyCenter\Actions\RegisterConsentPolicyAction::run($policyData);
}
```