Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

Commit

Permalink
Merge pull request #140 from petesiss/patch-2
Browse files Browse the repository at this point in the history
Added properties and methods to keep up with use of childrenAttributes
  • Loading branch information
dbu committed Mar 14, 2012
2 parents 36b4c96 + e4bdd86 commit 590124f
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/Symfony/Cmf/Bundle/MenuBundle/Document/MenuItem.php
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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(),
Expand Down

0 comments on commit 590124f

Please sign in to comment.