ILIAS  release_7 Revision v7.30-3-g800a261c036
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)
 ilTermsOfServiceDocumentLogicalAndCriteriaEvaluation constructor. More...
 
 withContextUser (ilObjUser $user)
 Returns an evaluator like this with the passed context user.
Parameters
ilObjUser$user
Returns
ilTermsOfServiceDocumentEvaluation
More...
 
 evaluateDocument (ilTermsOfServiceSignableDocument $document)
 
 document ()
 Determines a document based on the context of the concrete implementation.
Returns
ilTermsOfServiceSignableDocument
Exceptions
ilTermsOfServiceNoSignableDocumentFoundException
More...
 
 hasDocument ()
 
Returns
bool
More...
 

Protected Member Functions

 getMatchingDocuments ()
 

Protected Attributes

 $evaluation
 
 $user
 
 $matchingDocumentsByUser = []
 
 $possibleDocuments = []
 
 $log
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

ilTermsOfServiceDocumentLogicalAndCriteriaEvaluation constructor.

Parameters
ilTermsOfServiceDocumentCriteriaEvaluation$evaluation
ilObjUser$user
ilLogger$log
ilTermsOfServiceSignableDocument[]$possibleDocuments

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

References $evaluation, $log, $possibleDocuments, $user, and user().

+ Here is the call graph for this function:

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 92 of file class.ilTermsOfServiceSequentialDocumentEvaluation.php.

References getMatchingDocuments(), and user().

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

◆ evaluateDocument()

ilTermsOfServiceSequentialDocumentEvaluation::evaluateDocument ( ilTermsOfServiceSignableDocument  $document)

Implements ilTermsOfServiceDocumentEvaluation.

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

Referenced by getMatchingDocuments().

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

◆ getMatchingDocuments()

ilTermsOfServiceSequentialDocumentEvaluation::getMatchingDocuments ( )
protected
Returns
ilTermsOfServiceSignableDocument[]

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

References $matchingDocumentsByUser, evaluateDocument(), and user().

Referenced by document(), and hasDocument().

55  : array
56  {
57  if (!array_key_exists((int) $this->user->getId(), $this->matchingDocumentsByUser)) {
58  $this->matchingDocumentsByUser[(int) $this->user->getId()] = [];
59 
60  $this->log->debug(sprintf(
61  'Evaluating document for user "%s" (id: %s) ...',
62  $this->user->getLogin(),
63  $this->user->getId()
64  ));
65 
66  foreach ($this->possibleDocuments as $document) {
67  if ($this->evaluateDocument($document)) {
68  $this->matchingDocumentsByUser[(int) $this->user->getId()][] = $document;
69  }
70  }
71 
72  $this->log->debug(sprintf(
73  '%s matching document(s) found',
74  count($this->matchingDocumentsByUser[(int) $this->user->getId()])
75  ));
76  }
77 
78  return $this->matchingDocumentsByUser[(int) $this->user->getId()];
79  }
user()
Definition: user.php:4
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasDocument()

ilTermsOfServiceSequentialDocumentEvaluation::hasDocument ( )

Returns
bool

Implements ilTermsOfServiceDocumentEvaluation.

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

References getMatchingDocuments().

109  : bool
110  {
111  return count($this->getMatchingDocuments()) > 0;
112  }
+ 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 43 of file class.ilTermsOfServiceSequentialDocumentEvaluation.php.

References $user.

44  {
45  $clone = clone $this;
46  $clone->user = $user;
47  $clone->evaluation = $clone->evaluation->withContextUser($user);
48 
49  return $clone;
50  }
Interface ilTermsOfServiceDocumentEvaluation.

Field Documentation

◆ $evaluation

ilTermsOfServiceSequentialDocumentEvaluation::$evaluation
protected

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

Referenced by __construct().

◆ $log

ilTermsOfServiceSequentialDocumentEvaluation::$log
protected

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

Referenced by __construct().

◆ $matchingDocumentsByUser

ilTermsOfServiceSequentialDocumentEvaluation::$matchingDocumentsByUser = []
protected

◆ $possibleDocuments

ilTermsOfServiceSequentialDocumentEvaluation::$possibleDocuments = []
protected

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

Referenced by __construct().

◆ $user

ilTermsOfServiceSequentialDocumentEvaluation::$user
protected

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