Contao\FileTree::validator PHP Method

validator() protected method

Return an array if the "multiple" attribute is set
protected validator ( mixed $varInput ) : mixed
$varInput mixed
return mixed
    protected function validator($varInput)
    {
        // Store the order value
        if ($this->orderField != '') {
            $arrNew = array_map('StringUtil::uuidToBin', explode(',', \Input::post($this->strOrderName)));
            // Only proceed if the value has changed
            if ($arrNew !== $this->{$this->orderField}) {
                $this->Database->prepare("UPDATE {$this->strTable} SET tstamp=?, {$this->orderField}=? WHERE id=?")->execute(time(), serialize($arrNew), $this->activeRecord->id);
                $this->objDca->createNewVersion = true;
                // see #6285
            }
        }
        // Return the value as usual
        if ($varInput == '') {
            if ($this->mandatory) {
                $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['mandatory'], $this->strLabel));
            }
            return '';
        } elseif (strpos($varInput, ',') === false) {
            $varInput = \StringUtil::uuidToBin($varInput);
            return $this->multiple ? array($varInput) : $varInput;
        } else {
            $arrValue = array_filter(explode(',', $varInput));
            return $this->multiple ? array_map('StringUtil::uuidToBin', $arrValue) : \StringUtil::uuidToBin($arrValue[0]);
        }
    }