public static function factory($label, $link, array $params = array('icon' => 'tool-blue')) { $button = new self(); $button->setTitle($label); $button->setLink($link); $button->setDecoratorParams($params); return $button; }
public static function fromArray(\Doctrine\ORM\EntityManager $em, array $def, NavigationNode $parent = null) { $list = array(); foreach ($def as $nodeDef) { $title = $nodeDef[0]; $link = isset($nodeDef[1]) ? $nodeDef[1] : ''; $tooltip = isset($nodeDef[2]) ? $nodeDef[2] : ''; $children = isset($nodeDef[3]) ? $nodeDef[3] : null; $userGroups = isset($nodeDef[4]) ? $nodeDef[4] : null; $node = new self(); $node->setTitle($title); $node->setLink($link); $node->setTooltip($tooltip); $em->persist($node); if ($parent !== null) { $node->setParent($parent); } if (is_array($children)) { $list = array_merge($list, self::fromArray($em, $children, $node)); } if (is_array($userGroups)) { $node->setVisibleFor($userGroups); } $em->flush(); $list[] = $node; } return $list; }