ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilAccessibilityLogicalAndDocumentCriteriaEvaluation.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
3
8{
11
13 protected $user;
14
16 protected $log;
17
24 public function __construct(
28 ) {
29 $this->criterionTypeFactory = $criterionTypeFactory;
30 $this->user = $user;
31 $this->log = $log;
32 }
33
37 public function evaluate(ilAccessibilitySignableDocument $document) : bool
38 {
39 $this->log->debug(sprintf(
40 'Evaluating criteria for document "%s" (id: %s) and user "%s" (id: %s)',
41 $document->title(),
42 $document->id(),
43 $this->user->getLogin(),
44 $this->user->getId()
45 ));
46
47 foreach ($document->criteria() as $criterionAssignment) {
50 $criterionType = $this->criterionTypeFactory->findByTypeIdent($criterionAssignment->getCriterionId(), true);
51
52 $result = $criterionType->evaluate($this->user, $criterionAssignment->getCriterionValue());
53
54 $this->log->debug(sprintf(
55 'Criterion of type "%s", configured with %s evaluated: %s',
56 $criterionType->getTypeIdent(),
57 var_export($criterionAssignment->getCriterionValue()->toJson(), true),
58 var_export($result, true)
59 ));
60
61 if (!$result) {
62 return false;
63 }
64 }
65
66 return true;
67 }
68}
$result
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
__construct(ilAccessibilityCriterionTypeFactoryInterface $criterionTypeFactory, ilObjUser $user, ilLogger $log)
ilAccessibilityDocumentLogicalAndCriteriaEvaluation constructor.
Component logger with individual log levels by component id.
evaluate(ilAccessibilitySignableDocument $document)
Interface ilAccessibilitySignableDocument.