123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?php
- namespace Cube\Controller\Request;
- class Standard extends AbstractRequest
- {
- const DEFAULT_MODULE = 'App';
- const DEFAULT_CONTROLLER = 'Index';
- const DEFAULT_ACTION = 'Index';
-
- public function setRequestUri($requestUri = null)
- {
- if ($requestUri === null) {
-
-
- if (array_key_exists('REQUEST_URI', $_SERVER)) {
- $requestUri = $_SERVER['REQUEST_URI'];
- if ($baseUrl = $this->getBaseUrl()) {
- $requestUri = str_ireplace('//', '/', $this->_strReplaceFirst($baseUrl, '', $requestUri));
- }
- }
- }
- $this->_requestUri = $requestUri;
- return $this;
- }
-
- public function getModule()
- {
- if (!$this->_module) {
- $this->setModule(self::DEFAULT_MODULE);
- }
- return $this->_module;
- }
-
- public function getController()
- {
- if (!$this->_controller) {
- $this->setController(self::DEFAULT_CONTROLLER);
- }
- return $this->_controller;
- }
-
- public function getAction()
- {
- if (!$this->_action) {
- $this->setAction(self::DEFAULT_ACTION);
- }
- return $this->_action;
- }
- protected function _strReplaceFirst($search, $replace, $subject)
- {
- $pos = strpos($subject, $search);
- if ($pos !== false) {
- $subject = substr_replace($subject, $replace, $pos, strlen($search));
- }
- return $subject;
- }
- }
|