ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilTermsOfServiceLogicalAndDocumentCriteriaEvaluation.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
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(
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(), true),
59 var_export($result, true)
60 ));
61
62 if (!$result) {
63 return false;
64 }
65 }
66
67 return true;
68 }
69}
$result
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
Component logger with individual log levels by component id.
__construct(ilTermsOfServiceCriterionTypeFactoryInterface $criterionTypeFactory, ilObjUser $user, ilLogger $log)
ilTermsOfServiceDocumentLogicalAndCriteriaEvaluation constructor.
evaluate(ilTermsOfServiceSignableDocument $document)
Interface ilTermsOfServiceSignableDocument.