Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Added properties and methods to keep up with use of childrenAttributes #140

Merged
merged 1 commit into from Mar 14, 2012
Jump to file or symbol
Failed to load files and symbols.
+35 −0
Split
@@ -58,6 +58,20 @@ class MenuItem implements NodeInterface {
*/
protected $attributes;
+ /**
+ * Simulate a php hashmap in phpcr. This holds the keys.
+ *
+ * @PHPCRODM\String(multivalue=true)
+ */
+ protected $childrenAttributeKeys;
+
+ /**
+ * Simulate a php hashmap in phpcr.
+ *
+ * @PHPCRODM\String(multivalue=true)
+ */
+ protected $childrenAttributes;
+
/** @PHPCRODM\Children(filter="*item") */
protected $children;
@@ -166,6 +180,26 @@ public function setAttributes($attributes)
$this->attributeKeys = array_keys($attributes);
}
+ public function getChildrenAttributes()
+ {
+ if (is_null($this->childrenAttributeKeys)) {
+ return array();
+ }
+ $keys = $this->childrenAttributeKeys instanceof Collection ?
+ $this->childrenAttributeKeys->toArray() :
+ $this->childrenAttributeKeys;
+ $values = $this->childrenAttributes instanceof Collection ?
+ $this->childrenAttributes->toArray() :
+ $this->childrenAttributes;
+ return array_combine($keys, $values);
+ }
+
+ public function setChildrenAttributes($attributes)
+ {
+ $this->childrenAttributes = $attributes;
+ $this->childrenAttributeKeys = array_keys($attributes);
+ }
+
public function getChildren()
{
return $this->children;
@@ -178,6 +212,7 @@ public function getOptions()
'route' => $this->getRoute(),
'label' => $this->getLabel(),
'attributes' => $this->getAttributes(),
+ 'childrenAttributes' => $this->getChildrenAttributes(),
'display' => true,
'displayChildren' => true,
'content' => $this->getContent(),