I guess it is has something to do with ArrayAccess because $this
and the objects in $this->products[$key]
do implement ArrayAccess. However there is no magic __get
or __set
anywhere.
var_dump($this->products[$key]['selected_options'][$option_key]);
// Output: string(7) "Größe:S"
$this->products[$key]['selected_options'][$option_key] = "test";
var_dump($this->products[$key]['selected_options'][$option_key]);
// Output: string(7) "Größe:S"
Does someone have any idea what is wrong here?
Also note that this does work:
$this->products[$key]['selected_options'] = array($option_key => "test");
// Output: string(4) "test"
ArrayAccess for Products same for $this
(Cart) but with $products
instead of $data
:
class Product implements ArrayAccess
{
protected $data;
/* **** ArrayAccess **** */
public function offsetExists($offset) {
return isset($this->data[$offset]);
}
public function offsetGet($offset) {
return $this->data[$offset];
}
public function offsetSet($offset , $value) {
$this->data[$offset] = $value;
}
public function offsetUnset($offset) {
unset($this->data[$offset]);
}
}