ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilTermsOfServiceLogicalAndDocumentCriteriaEvaluation.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
9 {
12 
14  protected $user;
15 
17  protected $log;
18 
25  public function __construct(
28  \ilLogger $log
29  ) {
30  $this->criterionTypeFactory = $criterionTypeFactory;
31  $this->user = $user;
32  $this->log = $log;
33  }
34 
38  public function evaluate(\ilTermsOfServiceSignableDocument $document) : bool
39  {
40  $this->log->debug(sprintf(
41  'Evaluating criteria for document "%s" (id: %s) and user "%s" (id: %s)',
42  $document->title(),
43  $document->id(),
44  $this->user->getLogin(),
45  $this->user->getId()
46  ));
47 
48  foreach ($document->criteria() as $criterionAssignment) {
51  $criterionType = $this->criterionTypeFactory->findByTypeIdent($criterionAssignment->getCriterionId(), true);
52 
53  $result = $criterionType->evaluate($this->user, $criterionAssignment->getCriterionValue());
54 
55  $this->log->debug(sprintf(
56  'Criterion of type "%s", configured with %s evaluated: %s',
57  $criterionType->getTypeIdent(),
58  var_export($criterionAssignment->getCriterionValue()->toJson(), 1),
59  var_export($result, 1)
60  ));
61 
62  if (!$result) {
63  return false;
64  }
65  }
66 
67  return true;
68  }
69 }
__construct(\ilTermsOfServiceCriterionTypeFactoryInterface $criterionTypeFactory, \ilObjUser $user, \ilLogger $log)
ilTermsOfServiceDocumentLogicalAndCriteriaEvaluation constructor.
$result
user()
Definition: user.php:4
Interface ilTermsOfServiceSignableDocument.
Component logger with individual log levels by component id.
evaluate(\ilTermsOfServiceSignableDocument $document)