ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilMailCachedAddressType Class Reference
+ Inheritance diagram for ilMailCachedAddressType:
+ Collaboration diagram for ilMailCachedAddressType:

Public Member Functions

 __construct (protected ilMailAddressType $inner, protected bool $use_cache)
 
 validate (int $sender_id)
 Validates the parsed recipients and set errors accordingly. More...
 
 getErrors ()
 Returns a list of errors determined in the validation process. More...
 
 getAddress ()
 The address instance used for validation and user id lookup. More...
 
 resolve ()
 Returns an array of resolved user ids based on an address instance. More...
 
 resolve ()
 Returns an array of resolved user ids based on an address instance. More...
 
 validate (int $sender_id)
 Validates the parsed recipients and set errors accordingly. More...
 
 getErrors ()
 Returns a list of errors determined in the validation process. More...
 
 getAddress ()
 The address instance used for validation and user id lookup. More...
 

Static Public Member Functions

static clearCache ()
 

Static Protected Attributes

static array $usr_ids_by_address_cache = []
 
static array $is_valid_cache = []
 

Private Member Functions

 getCacheKey ()
 

Detailed Description

Definition at line 21 of file class.ilMailCachedAddressType.php.

Constructor & Destructor Documentation

◆ __construct()

ilMailCachedAddressType::__construct ( protected ilMailAddressType  $inner,
protected bool  $use_cache 
)

Definition at line 28 of file class.ilMailCachedAddressType.php.

29 {
30 }

Member Function Documentation

◆ clearCache()

static ilMailCachedAddressType::clearCache ( )
static

Definition at line 32 of file class.ilMailCachedAddressType.php.

32 : void
33 {
34 self::$is_valid_cache = [];
35 self::$usr_ids_by_address_cache = [];
36 }

Referenced by ilMailAddressTypesTest\setUp().

+ Here is the caller graph for this function:

◆ getAddress()

ilMailCachedAddressType::getAddress ( )

The address instance used for validation and user id lookup.

Implements ilMailAddressType.

Definition at line 59 of file class.ilMailCachedAddressType.php.

60 {
61 return $this->inner->getAddress();
62 }

Referenced by getCacheKey().

+ Here is the caller graph for this function:

◆ getCacheKey()

ilMailCachedAddressType::getCacheKey ( )
private

Definition at line 38 of file class.ilMailCachedAddressType.php.

38 : string
39 {
40 $address = $this->getAddress();
41 return (string) $address;
42 }
getAddress()
The address instance used for validation and user id lookup.

References getAddress().

Referenced by resolve(), and validate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getErrors()

ilMailCachedAddressType::getErrors ( )

Returns a list of errors determined in the validation process.

The errors should be reset everytime the validation is triggered.

Returns
list<ilMailError>
See also
ilMailAddressType::validate

Implements ilMailAddressType.

Definition at line 54 of file class.ilMailCachedAddressType.php.

54 : array
55 {
56 return $this->inner->getErrors();
57 }

◆ resolve()

ilMailCachedAddressType::resolve ( )

Returns an array of resolved user ids based on an address instance.

Returns
list<int>

Implements ilMailAddressType.

Definition at line 64 of file class.ilMailCachedAddressType.php.

64 : array
65 {
66 $cache_key = $this->getCacheKey();
67 if (!$this->use_cache || !isset(self::$usr_ids_by_address_cache[$cache_key])) {
68 self::$usr_ids_by_address_cache[$cache_key] = $this->inner->resolve();
69 }
70
71 return self::$usr_ids_by_address_cache[$cache_key];
72 }

References getCacheKey().

+ Here is the call graph for this function:

◆ validate()

ilMailCachedAddressType::validate ( int  $sender_id)

Validates the parsed recipients and set errors accordingly.

Parameters
int$sender_idThe id of the acting ILIAS user, can be used for permission checks etc.
See also
ilMailAddressType::getErrors

Implements ilMailAddressType.

Definition at line 44 of file class.ilMailCachedAddressType.php.

44 : bool
45 {
46 $cache_key = $this->getCacheKey();
47 if (!$this->use_cache || !isset(self::$is_valid_cache[$cache_key])) {
48 self::$is_valid_cache[$cache_key] = $this->inner->validate($sender_id);
49 }
50
51 return self::$is_valid_cache[$cache_key];
52 }

References getCacheKey().

+ Here is the call graph for this function:

Field Documentation

◆ $is_valid_cache

array ilMailCachedAddressType::$is_valid_cache = []
staticprotected

Definition at line 26 of file class.ilMailCachedAddressType.php.

◆ $usr_ids_by_address_cache

array ilMailCachedAddressType::$usr_ids_by_address_cache = []
staticprotected

Definition at line 24 of file class.ilMailCachedAddressType.php.


The documentation for this class was generated from the following file: