RouteBase.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. class RouteBase {
  3. public function route() {
  4. $task = V::get('_task', '', $_REQUEST);
  5. if (empty($task)) {
  6. $this->defaultAction();
  7. return;
  8. }
  9. $methodName = "{$task}Action";
  10. if (method_exists($this, $methodName)) {
  11. $this->{$methodName}();
  12. } else {
  13. die("Task '{$task}' not exists");
  14. }
  15. }
  16. public function defaultAction() {
  17. die("default task not implemented");
  18. }
  19. public function parseMessageFromStorageTestAction() {
  20. $msgs = V::get('msgs', '', $_GET);
  21. //echo $this->parseMessageFromStorage($msg);
  22. Lib::loadClass('StorageException');
  23. if (is_array($msgs)) {
  24. foreach ($msgs as $vMsg) {
  25. try {
  26. throw new StorageException($vMsg);
  27. } catch (Exception $e) {
  28. $vParsedMsg = $e->getMessage();
  29. echo " MSG: {$vMsg}\n";
  30. echo "PARSED: {$vParsedMsg}\n";
  31. echo "isMsgParsed(" . ($vMsg != $vParsedMsg) . ")\n\n";
  32. }
  33. }
  34. } else {
  35. throw new StorageException($msgs);
  36. }
  37. echo "\n\n";
  38. die("parseMessageFromStorage end");
  39. }
  40. public function parseMessageFromStorage($msg) {
  41. return $msg;
  42. }
  43. }