TYPO3 CMS  TYPO3_6-2
FileMinimumSizeValidator.php
Go to the documentation of this file.
1 <?php
3 
23 
29  const LOCALISATION_OBJECT_NAME = 'tx_form_system_validate_fileminimumsize';
30 
36  protected $minimum;
37 
43  public function __construct($arguments) {
44  $this->setMinimum($arguments['minimum']);
45  parent::__construct($arguments);
46  }
47 
54  public function isValid() {
55  if ($this->requestHandler->has($this->fieldName)) {
56  $fileValue = $this->requestHandler->getByMethod($this->fieldName);
57  $value = $fileValue['size'];
58  if ($value < $this->minimum) {
59  return FALSE;
60  }
61  }
62  return TRUE;
63  }
64 
71  public function setMinimum($minimum) {
72  $this->minimum = (int)$minimum;
73  return $this;
74  }
75 
83  protected function substituteValues($message) {
84  $message = str_replace('%minimum', \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($this->minimum), $message);
85  return $message;
86  }
87 
88 }