ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilTermsOfServiceSequentialDocumentEvaluation Class Reference

Interface ilTermsOfServiceSequentialDocumentEvaluation. More...

+ Inheritance diagram for ilTermsOfServiceSequentialDocumentEvaluation:
+ Collaboration diagram for ilTermsOfServiceSequentialDocumentEvaluation:

Public Member Functions

 __construct (ilTermsOfServiceDocumentCriteriaEvaluation $evaluation, ilObjUser $user, ilLogger $log, array $possibleDocuments)
 
 withContextUser (ilObjUser $user)
 Returns an evaluator like this with the passed context user. More...
 
 evaluateDocument (ilTermsOfServiceSignableDocument $document)
 Evaluates the passed document for the context given in the concrete implementation. More...
 
 document ()
 Determines a document based on the context of the concrete implementation. More...
 
 hasDocument ()
 

Protected Member Functions

 getMatchingDocuments ()
 

Protected Attributes

ilTermsOfServiceDocumentCriteriaEvaluation $evaluation
 
ilObjUser $user
 
array $matchingDocumentsByUser = []
 
array $possibleDocuments = []
 
ilLogger $log
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilTermsOfServiceSequentialDocumentEvaluation::__construct ( ilTermsOfServiceDocumentCriteriaEvaluation  $evaluation,
ilObjUser  $user,
ilLogger  $log,
array  $possibleDocuments 
)

Member Function Documentation

◆ document()

ilTermsOfServiceSequentialDocumentEvaluation::document ( )

Determines a document based on the context of the concrete implementation.

Returns
ilTermsOfServiceSignableDocument
Exceptions
ilTermsOfServiceNoSignableDocumentFoundException

Implements ilTermsOfServiceDocumentEvaluation.

Definition at line 90 of file class.ilTermsOfServiceSequentialDocumentEvaluation.php.

References getMatchingDocuments(), and ILIAS\Repository\user().

91  {
92  $matchingDocuments = $this->getMatchingDocuments();
93  if (count($matchingDocuments) > 0) {
94  return $matchingDocuments[0];
95  }
96 
98  'Could not find any terms of service document for the passed user (id: %s|login: %s)',
99  $this->user->getId(),
100  $this->user->getLogin()
101  ));
102  }
Interface ilTermsOfServiceSignableDocument.
+ Here is the call graph for this function:

◆ evaluateDocument()

ilTermsOfServiceSequentialDocumentEvaluation::evaluateDocument ( ilTermsOfServiceSignableDocument  $document)

Evaluates the passed document for the context given in the concrete implementation.

Parameters
ilTermsOfServiceSignableDocument$document
Returns
bool

Implements ilTermsOfServiceDocumentEvaluation.

Definition at line 85 of file class.ilTermsOfServiceSequentialDocumentEvaluation.php.

Referenced by getMatchingDocuments().

85  : bool
86  {
87  return $this->evaluation->evaluate($document);
88  }
+ Here is the caller graph for this function:

◆ getMatchingDocuments()

ilTermsOfServiceSequentialDocumentEvaluation::getMatchingDocuments ( )
protected
Returns
ilTermsOfServiceSignableDocument[]

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

References $matchingDocumentsByUser, evaluateDocument(), and ILIAS\Repository\user().

Referenced by document(), and hasDocument().

59  : array
60  {
61  if (!array_key_exists($this->user->getId(), $this->matchingDocumentsByUser)) {
62  $this->matchingDocumentsByUser[$this->user->getId()] = [];
63 
64  $this->log->debug(sprintf(
65  'Evaluating document for user "%s" (id: %s) ...',
66  $this->user->getLogin(),
67  $this->user->getId()
68  ));
69 
70  foreach ($this->possibleDocuments as $document) {
71  if ($this->evaluateDocument($document)) {
72  $this->matchingDocumentsByUser[$this->user->getId()][] = $document;
73  }
74  }
75 
76  $this->log->debug(sprintf(
77  '%s matching document(s) found',
78  count($this->matchingDocumentsByUser[$this->user->getId()])
79  ));
80  }
81 
82  return $this->matchingDocumentsByUser[$this->user->getId()];
83  }
evaluateDocument(ilTermsOfServiceSignableDocument $document)
Evaluates the passed document for the context given in the concrete implementation.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasDocument()

ilTermsOfServiceSequentialDocumentEvaluation::hasDocument ( )

Implements ilTermsOfServiceDocumentEvaluation.

Definition at line 104 of file class.ilTermsOfServiceSequentialDocumentEvaluation.php.

References getMatchingDocuments().

104  : bool
105  {
106  return count($this->getMatchingDocuments()) > 0;
107  }
+ Here is the call graph for this function:

◆ withContextUser()

ilTermsOfServiceSequentialDocumentEvaluation::withContextUser ( ilObjUser  $user)

Returns an evaluator like this with the passed context user.

Parameters
ilObjUser$user
Returns
ilTermsOfServiceDocumentEvaluation

Implements ilTermsOfServiceDocumentEvaluation.

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

References $user.

48  {
49  $clone = clone $this;
50  $clone->user = $user;
51  $clone->evaluation = $clone->evaluation->withContextUser($user);
52 
53  return $clone;
54  }
Interface ilTermsOfServiceDocumentEvaluation.

Field Documentation

◆ $evaluation

ilTermsOfServiceDocumentCriteriaEvaluation ilTermsOfServiceSequentialDocumentEvaluation::$evaluation
protected

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

Referenced by __construct().

◆ $log

ilLogger ilTermsOfServiceSequentialDocumentEvaluation::$log
protected

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

Referenced by __construct().

◆ $matchingDocumentsByUser

array ilTermsOfServiceSequentialDocumentEvaluation::$matchingDocumentsByUser = []
protected

◆ $possibleDocuments

array ilTermsOfServiceSequentialDocumentEvaluation::$possibleDocuments = []
protected

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

Referenced by __construct().

◆ $user

ilObjUser ilTermsOfServiceSequentialDocumentEvaluation::$user
protected

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