Phalcon Framework 4.1.2

Error: Call to undefined method Phalcon\Mvc\Router::getRewriteUri()

/srv/dietetykpro/sklep.dietetykpro.pl/cache/_srv_dietetykpro_sklep.dietetykpro.pl_themes_dietetykpro_main_frontend_notfound.twig.php (149)
#0unknown
#1Phalcon\Mvc\View\Engine\Volt->render
#2Phalcon\Mvc\View->engineRender
#3Phalcon\Mvc\View->processRender
#4Phalcon\Mvc\View->render
/srv/dietetykpro/sklep.dietetykpro.pl/app/vendor/Dispatcher/Plugin.php (116)
  1. <?php
  2.  
  3. namespace SH\Dispatcher;
  4.  
  5. use Phalcon\Di\Injectable;
  6. use Phalcon\Events\Event;
  7. use Phalcon\Http\ResponseInterface;
  8. use Phalcon\Mvc\Dispatcher;
  9.  
  10. /**
  11. * Class Plugin
  12. * @package SH\Dispatcher
  13. * @property \SH\Application $application
  14. */
  15. class Plugin extends Injectable
  16. {
  17. function beforeDispatch(Event $event, Dispatcher $dispatcher)
  18. {
  19. $controllerClass = $dispatcher->getControllerClass();
  20. $activeMethod = $dispatcher->getActiveMethod();
  21.  
  22. if (preg_match('/FrontendController/', $controllerClass) || preg_match('/AclController/', $controllerClass)) {
  23. $user = $this->user->getIdentity();
  24.  
  25. if ($user) {
  26. if ($user->role && $user->role !== 'su') {
  27. $annotations = $this->annotations->get($controllerClass);
  28.  
  29. if ($annotations->getClassAnnotations() && $annotations->getClassAnnotations()->has('Acl')) {
  30. $aclResource = $annotations->getClassAnnotations()->get('Acl');
  31. $aclResource = $aclResource->getNamedParameter('label');
  32.  
  33. $aclMethod = $annotations->getMethodsAnnotations();
  34.  
  35. if (isset($aclMethod[$activeMethod])) {
  36. $aclMethod = $aclMethod[$activeMethod];
  37.  
  38. if ($aclMethod->has('Acl')) {
  39. $aclMethod = $aclMethod->get('Acl');
  40. $aclMethod = $aclMethod->getNamedParameter('label');
  41.  
  42. if ($this->acl->isAllowed($user->role, $aclResource, $aclMethod) === false) {
  43. $this->response->redirect('/403');
  44.  
  45. return false;
  46. } else {
  47. return true;
  48. }
  49. }
  50. }
  51. }
  52. }
  53. }
  54. } else {
  55. $annotations = $this->annotations->get($controllerClass);
  56.  
  57. if ($annotations->getClassAnnotations() && $annotations->getClassAnnotations()->has('Acl')) {
  58. $aclResource = $annotations->getClassAnnotations()->get('Acl');
  59. $aclResource = $aclResource->getNamedParameter('label');
  60.  
  61. $aclMethod = $annotations->getMethodsAnnotations();
  62.  
  63. if (isset($aclMethod[$activeMethod])) {
  64. $aclMethod = $aclMethod[$activeMethod];
  65.  
  66. if ($aclMethod->has('Acl')) {
  67. $aclMethod = $aclMethod->get('Acl');
  68. $aclMethod = $aclMethod->getNamedParameter('label');
  69.  
  70. if ($this->acl->isAllowed($this->auth->getRoleName(), $aclResource, $aclMethod) === false) {
  71. if ($this->auth->isGuest) {
  72. $this->response->redirect('/admin/user/login');
  73. } else {
  74. $this->response->redirect('/admin/main/code403');
  75. }
  76.  
  77. return false;
  78. } else {
  79. return true;
  80. }
  81. }
  82. }
  83. }
  84. }
  85.  
  86. return true;
  87. }
  88.  
  89. function beforeDispatchLoop(Event $event, Dispatcher $dispatcher)
  90. {
  91. $module = $this->application->getModule($dispatcher->getModuleName());
  92.  
  93. if (is_array($module) && isset($module['className'])) {
  94. $module = $this->di->get($module['className']);
  95. }
  96. $namespace = $module->getNamespace();
  97. $namespace .= '\controllers';
  98.  
  99. $dispatcher->setNamespaceName($namespace);
  100. }
  101.  
  102. function afterDispatchLoop(Event $event, Dispatcher $dispatcher)
  103. {
  104. $results = $dispatcher->getReturnedValue();
  105.  
  106. if ($results instanceof ResponseInterface || $results === false) {
  107. $this->view->disable();
  108. } else {
  109. if (is_array($results) || is_null($results)) {
  110. if ($results) {
  111. $this->view->setVars($results);
  112. } else {
  113. $results = [];
  114. }
  115.  
  116. $this->view->render($this->router->getModuleName() . '/' . $dispatcher->getControllerName(), $dispatcher->getActionName(), $results);
  117. }
  118. }
  119. }
  120. }
#5SH\Dispatcher\Plugin->afterDispatchLoop
#6Phalcon\Events\Manager->fireQueue
#7Phalcon\Events\Manager->fire
#8Phalcon\Dispatcher\AbstractDispatcher->dispatch
#9Phalcon\Mvc\Application->handle
/srv/dietetykpro/sklep.dietetykpro.pl/app/vendor/Application.php (30)
  1. <?php
  2.  
  3. namespace SH;
  4.  
  5. use Phalcon\Application\Exception;
  6.  
  7. /**
  8. * Class Application
  9. * @package SH
  10. * @property \SH\Views\MenuGenerator $MenuGenerator
  11. */
  12. class Application extends \Phalcon\Mvc\Application
  13. {
  14. protected $_moduleNamespace = '';
  15.  
  16. public function handle($uri = null)
  17. {
  18. $nameSpaces = $this->loader->getNamespaces();
  19.  
  20. if (isset($nameSpaces['app\modules']) === false) {
  21. throw new Exception("namespace app modules not defined");
  22. }
  23.  
  24. $this->_moduleNamespace = $nameSpaces['app\modules'][0];
  25. $dirs = scandir($this->_moduleNamespace);
  26.  
  27. $modules = $this->handleModules($this->_moduleNamespace, $dirs);
  28. $this->registerModules($modules);
  29.  
  30. return parent::handle($uri);
  31. }
  32.  
  33. protected function handleModules(string $path, array $dirs): array
  34. {
  35. $modules = [];
  36.  
  37. foreach ($dirs as $dir) {
  38. $modulePath = "{$path}{$dir}";
  39. if (is_dir($modulePath) === false) {
  40. continue;
  41. } else {
  42. if (in_array($dir, ['.', '..'])) {
  43. continue;
  44. } else {
  45. if (file_exists($modulePath . "/Web.php") === false) {
  46. continue;
  47. }
  48. }
  49. }
  50.  
  51. $moduleClass = str_replace($this->_moduleNamespace, '', $modulePath);
  52. $moduleClass = str_replace('/', '\\', $moduleClass);
  53. $moduleClass = 'app\modules\\' . $moduleClass . '\Web';
  54.  
  55. $module = $this->getDI()->get($moduleClass);
  56. $module->registerAutoloaders($this->getDI());
  57. $module->registerServices($this->getDI());
  58.  
  59. if (file_exists($modulePath . '/params/router.php')) {
  60. require_once $modulePath . '/params/router.php';
  61. }
  62.  
  63. if (IS_ADMIN) {
  64. if (file_exists($modulePath . '/params/menu.php')) {
  65. require_once $modulePath . '/params/menu.php';
  66. }
  67. }
  68.  
  69. $modules[$dir] = ["className" => $moduleClass];
  70.  
  71. $subModules = "{$modulePath}/modules/";
  72. if (is_dir($subModules)) {
  73. $subDirs = scandir($subModules);
  74. $subModules = $this->handleModules($subModules, $subDirs);
  75.  
  76. $modules = array_merge($modules, $subModules);
  77. }
  78. }
  79.  
  80. return $modules;
  81. }
  82. }
#10SH\Application->handle
/srv/dietetykpro/sklep.dietetykpro.pl/public/index.php (59)
  1. <?php
  2.  
  3. $admin_dir = 'admin';
  4.  
  5. defined('BASE_PATH') or define('BASE_PATH', dirname(__DIR__));
  6. defined('APP_PATH') or define('APP_PATH', BASE_PATH . '/app');
  7. define ('IS_CONSOLE', false);
  8.  
  9. if (preg_match('/^\/' . $admin_dir . '\/$/', $_SERVER['REQUEST_URI'])) {
  10. header('Location: /admin');
  11. die;
  12. }
  13.  
  14. if (preg_match('/' . $admin_dir . '/', $_SERVER['REQUEST_URI'])) {
  15. defined('IS_ADMIN') or define('IS_ADMIN', true);
  16. } else {
  17. defined('IS_ADMIN') or define('IS_ADMIN', false);
  18. }
  19.  
  20. $config = null;
  21. $application = null;
  22.  
  23. try {
  24. /**
  25. * Include Autoloader
  26. */
  27. $loader = include APP_PATH . '/config/web/loader.php';
  28.  
  29. /**
  30. * The FactoryDefault Dependency Injector automatically registers
  31. * the services that provide a full stack framework.
  32. */
  33. $di = new \Phalcon\Di();
  34. $di->setShared('loader', $loader);
  35. /**
  36. * Read services
  37. */
  38. include APP_PATH . '/config/web/services.php';
  39.  
  40. /**
  41. * Get config service for use in inline setup below
  42. */
  43. $config = $di->getConfig();
  44.  
  45. if ($config->application->isDevelopment) {
  46. error_reporting(E_ALL);
  47. ini_set('display_errors', 1);
  48.  
  49. $debug = new \Phalcon\Debug();
  50. $debug->listen();
  51. }
  52.  
  53. /**
  54. * Handle the request
  55. */
  56. $application = new \SH\Application($di);
  57. $di->setShared('application', $application);
  58.  
  59. $application->handle($_SERVER['REQUEST_URI'])->send();
  60.  
  61. } catch (\Exception $e) {
  62. if (!(is_null($config) || is_null($application))) {
  63. if ($config->application->isDevelopment) {
  64. throw $e;
  65. } else {
  66. $application->response->redirect('/');
  67. }
  68. }
  69. }