123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- <?php
- namespace Cube\Navigation\Page;
- use Cube\Controller\Front;
- class Mvc extends AbstractPage
- {
-
- protected $_module;
-
- protected $_controller;
-
- protected $_action;
-
- protected $_params = array();
-
- public function getModule()
- {
- return $this->_module;
- }
-
- public function setModule($module)
- {
- if (!is_string($module) && $module !== null) {
- throw new \InvalidArgumentException(sprintf(
- "'module' must be a string or null, %s given.", gettype($module)));
- }
- $this->_module = $module;
- return $this;
- }
-
- public function getController()
- {
- return $this->_controller;
- }
-
- public function setController($controller)
- {
- if (!is_string($controller) && $controller !== null) {
- throw new \InvalidArgumentException(sprintf(
- "'controller' must be a string or null, %s given.", gettype($controller)));
- }
- $this->_controller = $controller;
- return $this;
- }
-
- public function getAction()
- {
- return $this->_action;
- }
-
- public function setAction($action)
- {
- if (!is_string($action) && $action !== null) {
- throw new \InvalidArgumentException(sprintf(
- "'action' must be a string or null, %s given.", gettype($action)));
- }
- $this->_action = $action;
- return $this;
- }
-
- public function getParams()
- {
- $params = array(
- 'module' => $this->_module,
- 'controller' => $this->_controller,
- 'action' => $this->_action,
- );
- foreach ($this->_params as $key => $value) {
- $params[$key] = $value;
- }
- return $params;
- }
-
- public function setParams(array $params = null)
- {
- $this->_params = (array) $params;
- return $this;
- }
-
- public function isActive($recursive = false)
- {
- if (!$this->_active) {
- $frontController = Front::getInstance();
- $request = $frontController->getRequest();
- $router = $frontController->getRouter();
- $mvcParams = array(
- 'module' => $this->_module,
- 'controller' => $this->_controller,
- 'action' => $this->_action,
- );
- $uri = $router->assemble(
- array_merge($mvcParams, $this->_params), null, false);
- if ($request->matchRequestUri($uri)) {
- $this->_active = true;
- return true;
- }
- }
- return parent::isActive($recursive);
- }
- }
|