null, 'flatname_checksum' => null, 'flatname' => null, 'flatvalue' => null, ]; protected $binaryProperties = [ 'var_checksum', 'flatname_checksum', ]; public static function generateForCustomVar(CustomVariable $var, Db $db) { $flatVars = static::forCustomVar($var, $db); foreach ($flatVars as $flat) { $flat->store(); } return $flatVars; } public static function forCustomVar(CustomVariable $var, Db $db) { $flat = array(); $varSum = $var->checksum(); $var->flatten($flat, $var->getKey()); $flatVars = array(); foreach ($flat as $name => $value) { $flatVar = static::create(array( 'var_checksum' => $varSum, 'flatname_checksum' => sha1($name, true), 'flatname' => $name, 'flatvalue' => $value, ), $db); $flatVar->store(); $flatVars[] = $flatVar; } return $flatVars; } }