class EntityData implements \ArrayAccess
{
+
+ protected $_offsetPrefix = null;
+
/**
* @var array
*/
public function set($offset, $value)
{
$offset = square_brackets_to_dots($offset);
- Arr::set($this->_data, $offset, $this->_fixValue($value));
+ Arr::set($this->_data, $this->_offset($offset), $this->_fixValue($value));
}
protected function _fixValue($value)
$dot = Arr::dot($value);
$res = [];
foreach ($dot as $k => $v) {
- Arr::set($res, square_brackets_to_dots($k), $v);
+ Arr::set($res, $this->_offset(square_brackets_to_dots($k)), $v);
}
return $res;
}
*/
public function exists($offset)
{
- return Arr::has($this->_data, $offset);
+ return Arr::has($this->_data, $this->_offset($offset));
}
/**
*/
public function unset($offset)
{
- Arr::set($this->_data, $offset, null);
+ Arr::set($this->_data, $this->_offset($offset), null);
}
/**
}
foreach ($offset as $key) {
- if (!Arr::has($this->_data, $key)) {
+ if (!Arr::has($this->_data, $this->_offset($key))) {
continue;
}
- $res = Arr::get($this->_data, $key, $default);
+ $res = Arr::get($this->_data, $this->_offset($key), $default);
// If an array value is saved without any items, it might be returned
// as a string "[]" when instead it should be an empty array...
*/
public function offsetUnset($offset)
{
- return $this->unset($offset);
+ $this->unset($offset);
}
/**
*/
public function __set($name, $value)
{
- return $this->set($name, $value);
+ $this->set($name, $value);
}
/**
return $this->_data;
}
+ /**
+ * @return null
+ */
+ public function getOffsetPrefix()
+ {
+ return $this->_offsetPrefix;
+ }
+
+ /**
+ * @param null $offsetPrefix
+ */
+ public function setOffsetPrefix($offsetPrefix): void
+ {
+ $this->_offsetPrefix = $offsetPrefix;
+ }
+
+ protected function _offset($offset)
+ {
+ return null === $this->_offsetPrefix ? $offset : $this->_offsetPrefix . $offset;
+ }
+
/**
* @param $entities CubistMagicAbstractModel[]
* @return PageData[]