remap_batch_items_for_complextype ( $items, $replace )

Remaps the custom item-key-value format used by Batchoperations to the more common ComplexList format. Internal use only.

Access

public static

Parameters

Parameter

Type

Required

Description

$items

array

Required

The item-key-value format passed by batch_put_attributes() and batch_delete_attributes().

$replace

boolean
array

Optional

The $replace value passed by batch_put_attributes() and batch_delete_attributes().

Returns

Type

Description

array

A CFComplexType-compatible mapping of parameters.

Source

Method defined in services/sdb.class.php | Toggle source view (43 lines) | View on GitHub

public static function remap_batch_items_for_complextype($items, $replace = false)
{
    $map = array(
        'Item' => array()
    );

    foreach ($items as $key => $value)
    {
        $node = array();
        $node['ItemName'] = $key;

        if (is_array($value))
        {
            $node['Attribute'] = array();

            foreach ($value as $k => $v)
            {
                $v = is_array($v) ? $v : array($v);

                foreach ($v as $vv)
                {
                    $n = array();
                    $n['Name'] = $k;
                    $n['Value'] = $vv;

                    if (
                        $replace === (boolean) true ||
                        (isset($replace[$key]) && array_search($k, $replace[$key], true) !== false)
                    )
                    {
                        $n['Replace'] = 'true';
                    }

                    $node['Attribute'][] = $n;
                }
            }
        }

        $map['Item'][] = $node;
    }

    return $map;
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback