MetaModels\Helper\ToolboxFile::convertValuesToMetaModels PHP Method

convertValuesToMetaModels() public static method

The output array will 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 convertValuesToMetaModels ( array $values ) : array
$values array The binary uuid values to convert.
return array
    public static function convertValuesToMetaModels($values)
    {
        if (!is_array($values)) {
            throw new \InvalidArgumentException('Invalid uuid list.');
        }
        $result = array('bin' => array(), 'value' => array(), 'path' => array());
        $models = \FilesModel::findMultipleByUuids(array_filter($values));
        if ($models === null) {
            return $result;
        }
        foreach ($models as $value) {
            $result['bin'][] = $value->uuid;
            $result['value'][] = self::uuidToString($value->uuid);
            $result['path'][] = $value->path;
        }
        return $result;
    }

Usage Example

Example #1
0
 /**
  * Take the raw data from the DB column and unserialize it.
  *
  * @param mixed $value The array of data from the database.
  *
  * @return array
  */
 public function unserializeData($value)
 {
     return ToolboxFile::convertValuesToMetaModels(deserialize($value, true));
 }