\EncryptedFieldTrait
Trait EncryptedFieldTrait
This is a trait shared by all EncryptedXXX data field classes. Currently it only contains methods and properties for an ability to define custom encryption keys at DataObject level, but perhaps the trait can be extended to cover all other methods that are currently duplicated in the EncryptedXXX classes.
Synopsis
trait EncryptedFieldTrait
{
- // members
- private Key|null $encryption_key = NULL;
- // methods
- public Key|null getEncryptionKey()
- public void setEncryptionKey()
- private void setEncryptionKeyFromRecord()
Hierarchy
Used by
Members
private
- $encryption_key — string|Defuse\Crypto\Key|null
Methods
private
- setEncryptionKeyFromRecord() — Uses a DataObject or $record array to retrieve a custom encryption/decryption key by calling that DataObject's provideEncryptionKey() method. If the method is not defined, does not alter the key which will be used.
public
- getEncryptionKey() — Returns a custom key if one is explicitly set for this field. If a key is not set using setEncryptionKey(), returns null, which will trigger the AtRestCryptoService to use the default global key set in the ENCRYPT_AT_REST_KEY constant.
- setEncryptionKey() — Sets an encryption key that will override the default key defined in the ENCRYPT_AT_REST_KEY constant.