MetaModels\Helper\ToolboxFile::convertValuesToDatabase PHP Méthode

convertValuesToDatabase() public static méthode

The input array must have the following layout: array( 'bin' => array() // list of the binary ids. 'value' => array() // list of the uuids. 'path' => array() // list of the paths. )
public static convertValuesToDatabase ( array $values ) : array
$values array The values to convert.
Résultat array
    public static function convertValuesToDatabase($values)
    {
        if (!(isset($values['bin']) && isset($values['value']) && isset($values['path']))) {
            throw new \InvalidArgumentException('Invalid file array');
        }
        $bin = array();
        foreach ($values['bin'] as $value) {
            $bin[] = $value;
        }
        return $bin;
    }

Usage Example

Exemple #1
0
 /**
  * Take the data from the system and serialize it for the database.
  *
  * @param mixed $mixValues The data to serialize.
  *
  * @return string An serialized array with binary data or a binary data.
  */
 public function serializeData($mixValues)
 {
     if ($mixValues === null) {
         $mixValues = array('bin' => array(), 'value' => array(), 'path' => array());
     }
     $arrData = ToolboxFile::convertValuesToDatabase($mixValues);
     // Check single file or multiple file.
     if ($this->get('file_multiple')) {
         $mixValues = serialize($arrData);
     } else {
         $mixValues = $arrData[0];
     }
     return $mixValues;
 }
All Usage Examples Of MetaModels\Helper\ToolboxFile::convertValuesToDatabase