Contao\Validator::isBinaryUuid PHP Method

isBinaryUuid() public static method

Valid binary UUID (version 1)
public static isBinaryUuid ( mixed $varValue ) : boolean
$varValue mixed The value to be validated
return boolean True if the value is a binary UUID
    public static function isBinaryUuid($varValue)
    {
        if (strlen($varValue) == 16) {
            return ($varValue & hex2bin('000000000000F000C000000000000000')) === hex2bin('00000000000010008000000000000000');
        }
        return false;
    }

Usage Example

 public function __construct($arrAttributes = null)
 {
     // check against arrAttributes, as 'onsubmit_callback' => 'multifileupload_moveFiles' does not provide valid attributes
     if ($arrAttributes !== null && !$arrAttributes['uploadFolder']) {
         throw new \Exception(sprintf($GLOBALS['TL_LANG']['ERR']['noUploadFolderDeclared'], $this->name));
     }
     $arrAttributes['uploadAction'] = static::$uploadAction;
     if (TL_MODE == 'FE') {
         $arrAttributes['uploadActionParams'] = http_build_query(AjaxAction::getParams(MultiFileUpload::NAME, static::$uploadAction));
     }
     $arrAttributes['addRemoveLinks'] = isset($arrAttributes['addRemoveLinks']) ? $arrAttributes['addRemoveLinks'] : true;
     if (!is_array($arrAttributes['value']) && !Validator::isBinaryUuid($arrAttributes['value'])) {
         $arrAttributes['value'] = json_decode($arrAttributes['value']);
     }
     // bin to string -> never pass binary to the widget!!
     if ($arrAttributes['value']) {
         if (is_array($arrAttributes['value'])) {
             $arrAttributes['value'] = array_map(function ($val) {
                 return \Validator::isBinaryUuid($val) ? \StringUtil::binToUuid($val) : $val;
             }, $arrAttributes['value']);
         } else {
             $arrAttributes['value'] = array(\Validator::isBinaryUuid($arrAttributes['value']) ? \StringUtil::binToUuid($arrAttributes['value']) : $arrAttributes['value']);
         }
     }
     parent::__construct($arrAttributes);
     $this->objUploader = new MultiFileUpload($arrAttributes);
     // add onsubmit_callback: move files after form submission
     $GLOBALS['TL_DCA'][$this->strTable]['config']['onsubmit_callback']['multifileupload_moveFiles'] = array('HeimrichHannot\\MultiFileUpload\\FormMultiFileUpload', 'moveFiles');
     Ajax::runActiveAction(MultiFileUpload::NAME, MultiFileUpload::ACTION_UPLOAD, $this);
 }
All Usage Examples Of Contao\Validator::isBinaryUuid