ILIAS  release_7 Revision v7.30-3-g800a261c036
FileNamePolicyStack.php
Go to the documentation of this file.
1<?php
2
4
11{
15 protected $stack = [];
16
17 public function addPolicy(FileNamePolicy $policy) : void
18 {
19 $this->stack[] = $policy;
20 }
21
22 public function isValidExtension(string $extension) : bool
23 {
24 foreach ($this->stack as $policy) {
25 if (!$policy->isValidExtension($extension)) {
26 return false;
27 }
28 }
29 return true;
30 }
31
32 public function isBlockedExtension(string $extension) : bool
33 {
34 foreach ($this->stack as $policy) {
35 if (!$policy->isBlockedExtension($extension)) {
36 return false;
37 }
38 }
39 return true;
40 }
41
42 public function prepareFileNameForConsumer(string $filename_with_extension) : string
43 {
44 foreach ($this->stack as $policy) {
45 $filename_with_extension = $policy->prepareFileNameForConsumer($filename_with_extension);
46 }
47 return $filename_with_extension;
48 }
49
50 public function check(string $extension) : bool
51 {
52 foreach ($this->stack as $policy) {
53 $policy->check($extension);
54 }
55 return true;
56 }
57
58}
An exception for terminatinating execution or to throw for unit testing.
prepareFileNameForConsumer(string $filename_with_extension)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...