ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilMailCachedAddressType Class Reference

Class ilMailCachedAddressType. More...

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

Public Member Functions

 __construct (ilMailAddressType $inner, 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 ()
 

Protected Attributes

ilMailAddressType $inner
 
bool $useCache = true
 

Static Protected Attributes

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

Private Member Functions

 getCacheKey ()
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

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

References $inner, and $useCache.

34  {
35  $this->inner = $inner;
36  $this->useCache = $useCache;
37  }

Member Function Documentation

◆ clearCache()

static ilMailCachedAddressType::clearCache ( )
static

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

Referenced by ilMailAddressTypesTest\setUp().

39  : void
40  {
41  self::$isValidCache = [];
42  self::$usrIdsByAddressCache = [];
43  }
+ 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 67 of file class.ilMailCachedAddressType.php.

Referenced by getCacheKey().

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

◆ getCacheKey()

ilMailCachedAddressType::getCacheKey ( )
private

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

References getAddress().

Referenced by resolve(), and validate().

45  : string
46  {
47  $address = $this->getAddress();
48  return (string) $address;
49  }
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 62 of file class.ilMailCachedAddressType.php.

62  : array
63  {
64  return $this->inner->getErrors();
65  }

◆ resolve()

ilMailCachedAddressType::resolve ( )

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

Returns
int[]

Implements ilMailAddressType.

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

References getCacheKey().

72  : array
73  {
74  $cacheKey = $this->getCacheKey();
75 
76  if (!$this->useCache || !isset(self::$usrIdsByAddressCache[$cacheKey])) {
77  self::$usrIdsByAddressCache[$cacheKey] = $this->inner->resolve();
78  }
79 
80  return self::$usrIdsByAddressCache[$cacheKey];
81  }
+ 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 51 of file class.ilMailCachedAddressType.php.

References getCacheKey().

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

Field Documentation

◆ $inner

ilMailAddressType ilMailCachedAddressType::$inner
protected

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

Referenced by __construct().

◆ $isValidCache

array ilMailCachedAddressType::$isValidCache = []
staticprotected

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

◆ $useCache

bool ilMailCachedAddressType::$useCache = true
protected

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

Referenced by __construct().

◆ $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: