| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- class RouteBase {
- public function route() {
- $task = V::get('_task', '', $_REQUEST);
- if (empty($task)) {
- $this->defaultAction();
- return;
- }
- $methodName = "{$task}Action";
- if (method_exists($this, $methodName)) {
- $this->{$methodName}();
- } else {
- die("Task '{$task}' not exists");
- }
- }
- public function defaultAction() {
- die("default task not implemented");
- }
- public function runTask($task) {
- if (empty($task)) throw new Exception("Empty method name");
- $methodName = "{$task}Action";
- if (!method_exists($this, $methodName)) {
- throw new Exception("Task '{$task}' not exists");
- }
- $this->{$methodName}();
- }
- public function runMethod($methodName) {
- if (empty($methodName)) throw new Exception("Empty method name");
- if (!method_exists($this, $methodName)) {
- throw new Exception("Task '{$methodName}' not exists");
- }
- $this->{$methodName}();
- }
- public function parseMessageFromStorageTestAction() {
- $msgs = V::get('msgs', '', $_GET);
- //echo $this->parseMessageFromStorage($msg);
- Lib::loadClass('StorageException');
- if (is_array($msgs)) {
- foreach ($msgs as $vMsg) {
- try {
- throw new StorageException($vMsg);
- } catch (Exception $e) {
- $vParsedMsg = $e->getMessage();
- echo " MSG: {$vMsg}\n";
- echo "PARSED: {$vParsedMsg}\n";
- echo "isMsgParsed(" . ($vMsg != $vParsedMsg) . ")\n\n";
- }
- }
- } else {
- throw new StorageException($msgs);
- }
- echo "\n\n";
- die("parseMessageFromStorage end");
- }
- public function parseMessageFromStorage($msg) {
- return $msg;
- }
- public function parseMessageFromMsgsSystem($msg) {
- return $msg;
- }
- public function runByMessageFromMsgsSystem($msg, & $execNotes) {
- }
- public function handleAuth() {
- User::authByRequest();
- }
- }
|