fewbricks\bricks\brick::set_data_item PHP Method

set_data_item() public method

Use this to set custom data for the brick.
public set_data_item ( $item_name, $value, boolean $prepend_this_name = true, boolean $group_name = false )
$item_name string The name of the item.
$value mixed The value of the item.
$prepend_this_name boolean If the item name should be prepended with the name of the brick. This is an unfortunate left over from an early version. But it would cause a lot of trouble to remove it now so we leave it be.
$group_name boolean Use this if you want to create groups of data.
    public function set_data_item($item_name, $value, $prepend_this_name = true, $group_name = false)
    {
        if ($prepend_this_name) {
            $item_name = $this->name . '_' . $item_name;
            if ($group_name !== false) {
                $group_name = $this->name . '_' . $group_name;
            }
        }
        if ($group_name === false) {
            $this->data[$item_name] = $value;
        } else {
            $this->data[$group_name][$item_name] = $value;
        }
    }