PHP code example of goldnead / statamic-identity-contracts
1. Go to this page and download the library: Download goldnead/statamic-identity-contracts library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
goldnead / statamic-identity-contracts example snippets
use Goldnead\IdentityContracts\Facades\IdentityContext;
IdentityContext::current(); // actor behind this execution context
IdentityContext::resolve($user); // any subject → Identity
IdentityContext::actingAs($actor, fn () => …); // pin an actor for a job or import
class User extends Authenticatable implements ProvidesIdentity
{
public function toIdentity(): Identity
{
return Identity::user($this->id, $this->email, $this->name, $this->contact_uuid);
}
}
'resolve_from_auth' => true, // let current() fall back to the auth guard
'system_id' => 'system', // actor id for schedulers, webhooks, workers
'anonymous' => [
'enabled' => true,
'persist' => true,
'session_key' => 'identity_anonymous_id',
],