Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Dodanie nowego widoku do aplikacji.
cykcykacz
post
Post #1





Grupa: Zarejestrowani
Postów: 550
Pomógł: 9
Dołączył: 29.05.2009
Skąd: Ostrów Wielkopolski

Ostrzeżenie: (0%)
-----


Witam,
dostałem aplikację, w której nie wiem dlaczego ale nie widzi nowej dodanej akcji/widoku.
Dostaję taki komunikat "Action Helper by name xxxxxAction not found"
Pewnie chodzi o ścieżki route, ale nie wiem gdzie są zdefiniowane.
Plik index.php
  1. <?php
  2. define(ROOT_PATH, realpath(dirname(__FILE__) . '/..'));
  3.  
  4.  
  5. . PATH_SEPARATOR . ROOT_PATH . '/library'
  6. . PATH_SEPARATOR . ROOT_PATH . '/application/default/models/'
  7. );
  8.  
  9. require_once 'Zend/Loader/Autoloader.php';
  10.  
  11. $autoloader = Zend_Loader_Autoloader::getInstance();
  12. $autoloader->setFallbackAutoloader(true);
  13.  
  14. try {
  15. ini_set('memory_limit', '128M');
  16.  
  17. $frontend = array('master_file' => ROOT_PATH . '/config/route.ini', 'automatic_serialization' => true);
  18. $backend = array('cache_dir' => ROOT_PATH . '/temporary/cache/config');
  19. $cache = Zend_Cache::factory('File', 'File', $frontend, $backend);
  20.  
  21. if (!$config = $cache->load('route')) {
  22. $config = new Zend_Config_Ini(ROOT_PATH . '/config/route.ini', 'routes');
  23. $cache->save($config, 'route');
  24. }
  25.  
  26.  
  27. require_once 'Core/Controller/Plugin/Cache.php';
  28.  
  29. $router = new Core_Controller_Router_Rewrite();
  30. $router->addConfig($config, 'route');
  31.  
  32.  
  33. $fc = Zend_Controller_Front::getInstance();
  34. $fc->throwExceptions(true);
  35. $fc->setParam('noViewRenderer', true);
  36. $fc->setRouter($router);
  37. $fc->addModuleDirectory(ROOT_PATH . '/application');
  38. $fc->registerPlugin(new Core_Controller_Plugin_Locale());
  39. $fc->registerPlugin(new Core_Controller_Plugin_Runtime());
  40. $fc->registerPlugin(new Core_Controller_Plugin_Acl());
  41. $fc->registerPlugin(new Core_Controller_Plugin_Layout());
  42. $fc->dispatch();
  43. } catch (Exception $e) {
  44. echo $e->getMessage();
  45. }


route.ini
Kod
; ================= trasy statyczne ============================================
route.error403.type                = "Zend_Controller_Router_Route_Static"
route.error403.route               = "nie_masz_dostepu"
route.error403.defaults.module     = default
route.error403.defaults.controller = error
route.error403.defaults.action     = display
route.error403.defaults.code       = 403


Jeszcze są dwa takie pliczki:
rewrite.php
  1. final class Core_Controller_Router_Rewrite extends Zend_Controller_Router_Rewrite
  2. {
  3.  
  4. public function addDefaultRoutes()
  5. {
  6. if (!$this->hasRoute('default')) {
  7.  
  8. $dispatcher = $this->getFrontController()->getDispatcher();
  9. $request = $this->getFrontController()->getRequest();
  10.  
  11. $compat = new Core_Controller_Router_Route_Module(array(), $dispatcher, $request);
  12.  
  13. $this->_routes = array_merge(array('default' => $compat), $this->_routes);
  14. }
  15. }
  16. }

rote.php
  1. final class Core_Controller_Router_Route_Module extends Zend_Controller_Router_Route_Module
  2. {
  3.  
  4. protected $_languageKey = 'language';
  5.  
  6.  
  7. public function match($path)
  8. {
  9. $this->_setRequestKeys();
  10.  
  11. $values = array();
  12. $params = array();
  13. $path = trim($path, self::URI_DELIMITER);
  14.  
  15. if ($path != '') {
  16. $path = explode(self::URI_DELIMITER, $path);
  17.  
  18. if (ereg('^([a-z]{2})$', $path[0])) {
  19. $params[$this->_languageKey] = array_shift($path);
  20. }
  21.  
  22. if ($this->_dispatcher && $this->_dispatcher->isValidModule($path[0])) {
  23. $values[$this->_moduleKey] = array_shift($path);
  24. $this->_moduleValid = true;
  25. }
  26.  
  27. if (count($path) && !empty($path[0])) {
  28. $values[$this->_controllerKey] = array_shift($path);
  29. }
  30.  
  31. if (count($path) && !empty($path[0])) {
  32. $values[$this->_actionKey] = array_shift($path);
  33. }
  34.  
  35. if ($numSegs = count($path)) {
  36. for ($i = 0; $i < $numSegs; $i = $i + 2) {
  37. $key = urldecode($path[$i]);
  38. $val = isset($path[$i + 1]) ? urldecode($path[$i + 1]) : null;
  39. $params[$key] = $val;
  40. }
  41. }
  42. }
  43.  
  44. $this->_values = $values + $params;
  45.  
  46. return $this->_values + $this->_defaults;
  47. }
  48.  
  49. public function assemble($data = array(), $reset = false, $encode = false)
  50. {
  51. if (!$this->_keysSet) {
  52. $this->_setRequestKeys();
  53. }
  54.  
  55. $params = (!$reset) ? $this->_values : array();
  56.  
  57. foreach ($data as $key => $value) {
  58. if ($value !== null) {
  59. $params[$key] = $value;
  60. } elseif (isset($params[$key])) {
  61. unset($params[$key]);
  62. }
  63. }
  64.  
  65. $params += $this->_defaults;
  66.  
  67. $url = '';
  68.  
  69. $lang = $params[$this->_languageKey];
  70. unset($params[$this->_languageKey]);
  71.  
  72. if ($this->_moduleValid || array_key_exists($this->_moduleKey, $data)) {
  73. if ($params[$this->_moduleKey] != $this->_defaults[$this->_moduleKey]) {
  74. $module = $params[$this->_moduleKey];
  75. }
  76. }
  77. unset($params[$this->_moduleKey]);
  78.  
  79. $controller = $params[$this->_controllerKey];
  80. unset($params[$this->_controllerKey]);
  81.  
  82. $action = $params[$this->_actionKey];
  83. unset($params[$this->_actionKey]);
  84.  
  85. foreach ($params as $key => $value) {
  86. $url .= '/' . $key;
  87. $url .= '/' . $value;
  88. }
  89.  
  90. if (!empty($url) || $action !== $this->_defaults[$this->_actionKey]) {
  91. $url = '/' . $action . $url;
  92. }
  93.  
  94. if (!empty($url) || $controller !== $this->_defaults[$this->_controllerKey]) {
  95. $url = '/' . $controller . $url;
  96. }
  97.  
  98. if (isset($module)) {
  99. $url = '/' . $module . $url;
  100. }
  101.  
  102. if (isset($lang)) {
  103. $url = '/' . $lang . $url;
  104. }
  105.  
  106. return ltrim($url, self::URI_DELIMITER);
  107. }
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 05:24