/** * [__call description] * @param [type] $method [description] * @param [type] $parameters [description] * @return [type] [description] */ public function __call($method, $parameters) { if (preg_match("#^set([a-z0-9]+)Type\$#is", $method, $match)) { $method = 'setMenuType'; if (count($parameters) == 2) { $parameters[] = false; } $parameters = array_merge($parameters, array('menu' => Stringy::camel_case($match[1]))); } return call_user_func_array(array(static::container(), $method), $parameters); }
public function render($attributes, $node) { $structure = $this->generate(); $structure = $this->sortItems($structure); if (!isset($attributes['class'])) { $attributes['class'] = ''; } $attributesString = ''; $return = ''; if ($this->type === 'default') { $attributes['class'] .= " nav-{$this->name}"; foreach ($attributes as $attribute => $value) { $attributesString .= " {$attribute}=\"{$value}\" "; } $return .= "<{$node} {$attributesString}>"; $return .= $this->renderDetail($structure); $return .= "</{$node}>"; return $return; } else { $attributes['class'] .= " nav-{$this->name}"; foreach ($attributes as $attribute => $value) { $attributesString .= " {$attribute}=\"{$value}\" "; } $class = $this->stylesLocation . '\\Styles'; if (!class_exists($class)) { throw new \Exception("{$class} does not exist"); } $style = new $class(); $method = Stringy::camel_case("render-{$this->type}"); if (!class_exists($class, $method)) { throw new \Exception("{$method} does not exist"); } $return .= "<{$node} {$attributesString}>"; $return .= $style->{$method}($structure); $return .= "</{$node}>"; return $return; } }
public function render($name = false, $attributes = array(), $node = 'ul') { if (isset($this->renders[Stringy::camel_case($name)])) { return $this->renders[Stringy::camel_case($name)]; } if (!$name) { $this->navigations['pmDefaultMenu'] = new MenuContainerNavigation('pmDefaultMenu'); while (count($this->items) !== 0) { $item = array_shift($this->items); $this->navigations['pmDefaultMenu']->addItem($item); } $this->renders[$name] = ''; foreach ($this->navigations as $navigation) { $this->renders[$name] .= $navigation->render($attributes, $node); } return $this->renders[$name]; } else { $name = Stringy::camel_case($name); if (!isset($this->navigations[$name])) { // This gets annoying! // Throw new \Exception( "Navigation '{$name}' does not exist. Cannot process render." ); return false; } $this->renders[$name] = $this->navigations[$name]->render($attributes, $node); return $this->renders[$name]; } }