action = $action; } static function make($action) { return new State($action); } public function addTitle($name, $url = array()) { $this->titles [] = array($name, $url); return $this; } public function addState(State $state) { $this->states [$state->getAction()] = $state; return $this; } public function getAction() { return $this->action; } function checkAction($action, &$list) { if ($this->action == $action) { array_push($list, $this); return true; } else { foreach ($this->states as $state) { if ($state->checkAction($action, $list)) { array_push($list, $this); return true; } } } return false; } function makeTitle($module) { foreach ($this->titles as $item) { $module->path->addMenuItem($module->nUrl($this->action, $item[1]), $item[0]); } } function getPath($module, $action) { $list = array(); if ($this->checkAction($action, $list)) { foreach (array_reverse($list) as $item) { $item->makeTitle($module); } } else { $this->makeTitle($module); } } } /* $path = State::make('index') ->addState(State::make('form')) ->addState(State::make('view')); $path->getPath(0, 'form'); */