ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilMailCachedAddressType Class Reference

Class ilMailCachedAddressType. More...

+ Inheritance diagram for ilMailCachedAddressType:
+ Collaboration diagram for ilMailCachedAddressType:

Public Member Functions

 __construct (protected ilMailAddressType $inner, protected bool $useCache)
 
 validate (int $senderId)
 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...
 

Static Public Member Functions

static clearCache ()
 

Static Protected Attributes

static array $usrIdsByAddressCache = []
 
static array $isValidCache = []
 

Private Member Functions

 getCacheKey ()
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

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

32  {
33  }

Member Function Documentation

◆ clearCache()

static ilMailCachedAddressType::clearCache ( )
static

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

Referenced by ilMailAddressTypesTest\setUp().

35  : void
36  {
37  self::$isValidCache = [];
38  self::$usrIdsByAddressCache = [];
39  }
+ 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 63 of file class.ilMailCachedAddressType.php.

Referenced by getCacheKey().

64  {
65  return $this->inner->getAddress();
66  }
Class ilMailAddress.
+ Here is the caller graph for this function:

◆ getCacheKey()

ilMailCachedAddressType::getCacheKey ( )
private

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

References getAddress().

Referenced by resolve(), and validate().

41  : string
42  {
43  $address = $this->getAddress();
44  return (string) $address;
45  }
getAddress()
The address instance used for validation and user id lookup.
+ 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
ilMailError[]
See also
ilMailAddressType::validate

Implements ilMailAddressType.

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

58  : array
59  {
60  return $this->inner->getErrors();
61  }

◆ resolve()

ilMailCachedAddressType::resolve ( )

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

Returns
int[]

Implements ilMailAddressType.

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

References getCacheKey().

68  : array
69  {
70  $cacheKey = $this->getCacheKey();
71 
72  if (!$this->useCache || !isset(self::$usrIdsByAddressCache[$cacheKey])) {
73  self::$usrIdsByAddressCache[$cacheKey] = $this->inner->resolve();
74  }
75 
76  return self::$usrIdsByAddressCache[$cacheKey];
77  }
+ Here is the call graph for this function:

◆ validate()

ilMailCachedAddressType::validate ( int  $senderId)

Validates the parsed recipients and set errors accordingly.

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

Implements ilMailAddressType.

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

References getCacheKey().

47  : bool
48  {
49  $cacheKey = $this->getCacheKey();
50 
51  if (!$this->useCache || !isset(self::$isValidCache[$cacheKey])) {
52  self::$isValidCache[$cacheKey] = $this->inner->validate($senderId);
53  }
54 
55  return self::$isValidCache[$cacheKey];
56  }
+ Here is the call graph for this function:

Field Documentation

◆ $isValidCache

array ilMailCachedAddressType::$isValidCache = []
staticprotected

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

◆ $usrIdsByAddressCache

array ilMailCachedAddressType::$usrIdsByAddressCache = []
staticprotected

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


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