public function partial($sViewScript, $mBind = null) { $partial = new self(); if (null === $mBind) { $mBind = get_object_vars($this); } foreach ($mBind as $key => $val) { $partial->{$key} = $val; } $partial->setView($sViewScript); return $partial->render(); }
/** * Factory method for MenuEntry * Set parent, view and decorator to the MenuEntry * @param string $type type of menuentry * @param string $param1 * @param string $param2 * @return X_VlcShares_Elements_MenuEntry|X_VlcShares_Elements_Menu */ protected function addEntry($type, $param1 = null, $param2 = null) { switch ($type) { case self::SUBMENU: $entry = new self($this); $entry->setView($this->view)->setLevel($this->getOption('menu.level') + 1)->setLabel($param1)->setHref($param2); // I have to assign a subdecorator if the current decorator // of this implement ParentDecoratorInterface // or a default submenu decorator $parentDecorator = $this->getDecorator(); if ($parentDecorator instanceof X_VlcShares_Skins_ParentDecoratorInterface) { $decorator = $parentDecorator->getSubDecorator(X_VlcShares_Skins_Manager::MENUENTRY_SUBMENU); } else { $decorator = X_VlcShares_Skins_Manager::i()->getDecorator(X_VlcShares_Skins_Manager::MENUENTRY_SUBMENU); } $entry->setDecorator($decorator); $this->_entries[] = $entry; return $entry; // add menu has to return a reference to the new submenu // add menu has to return a reference to the new submenu case self::LABEL: $entry = new X_VlcShares_Elements_MenuEntry($this); $entry->setView($this->view)->setLabel($param1); $parentDecorator = $this->getDecorator(); if ($parentDecorator instanceof X_VlcShares_Skins_ParentDecoratorInterface) { $decorator = $parentDecorator->getSubDecorator(X_VlcShares_Skins_Manager::MENUENTRY_LABEL); } else { $decorator = X_VlcShares_Skins_Manager::i()->getDecorator(X_VlcShares_Skins_Manager::MENUENTRY_LABEL); } $entry->setDecorator($decorator); $this->_entries[] = $entry; break; case self::BUTTON: $entry = new X_VlcShares_Elements_MenuEntry($this); $entry->setView($this->view)->setLabel($param1)->setHref($param2); $parentDecorator = $this->getDecorator(); if ($parentDecorator instanceof X_VlcShares_Skins_ParentDecoratorInterface) { $decorator = $parentDecorator->getSubDecorator(X_VlcShares_Skins_Manager::MENUENTRY_BUTTON); } else { $decorator = X_VlcShares_Skins_Manager::i()->getDecorator(X_VlcShares_Skins_Manager::MENUENTRY_BUTTON); } $entry->setDecorator($decorator); $this->_entries[] = $entry; break; case self::LINK: default: // all other types work as LINK $entry = new X_VlcShares_Elements_MenuEntry($this); $entry->setView($this->view)->setLabel($param1)->setHref($param2); $parentDecorator = $this->getDecorator(); if ($parentDecorator instanceof X_VlcShares_Skins_ParentDecoratorInterface) { $decorator = $parentDecorator->getSubDecorator(X_VlcShares_Skins_Manager::MENUENTRY_LINK); } else { $decorator = X_VlcShares_Skins_Manager::i()->getDecorator(X_VlcShares_Skins_Manager::MENUENTRY_LINK); } $entry->setDecorator($decorator); $this->_entries[] = $entry; break; } return $this; }