Skip to content
Snippets Groups Projects
Commit 0abf21a7 authored by efalcy's avatar efalcy
Browse files

add custom fields

parent 80f332b9
Branches
No related merge requests found
......@@ -17,6 +17,7 @@ class PropertyBag implements \IteratorAggregate
* @var array
*/
protected $elements = [];
protected $xprops = [];
/**
* Creates a new Property with $name, $value and $params.
......@@ -60,6 +61,10 @@ class PropertyBag implements \IteratorAggregate
public function add(Property $property)
{
$name = $property->getName();
if ('X-' == substr($name, 0, 2)) {
$this->xprops[] = $property;
return $this;
}
if (isset($this->elements[$name])) {
throw new \Exception("Property with name '{$name}' already exists");
......@@ -72,6 +77,6 @@ class PropertyBag implements \IteratorAggregate
public function getIterator()
{
return new \ArrayObject($this->elements);
return new \ArrayObject($this->elements + $this->xprops);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment