| @@ 89-109 (lines=21) @@ | ||
| 86 | * @return object|null |
|
| 87 | * The table from the config, or NULL if there is no table |
|
| 88 | */ |
|
| 89 | public function getTableIfExists() |
|
| 90 | { |
|
| 91 | // get our table name from the constructor |
|
| 92 | $tableName = $this->args[0]; |
|
| 93 | ||
| 94 | // what are we doing? |
|
| 95 | $log = Log::usingLog()->startAction("get '{$tableName}' table from runtime config"); |
|
| 96 | ||
| 97 | // get the table config |
|
| 98 | $tables = RuntimeTable::fromRuntimeTables()->getAllTablesSilently(); |
|
| 99 | ||
| 100 | // make sure we have a table |
|
| 101 | if (!isset($tables->$tableName)){ |
|
| 102 | $log->endAction("table '{$tableName}' does not exist"); |
|
| 103 | return null; |
|
| 104 | } |
|
| 105 | ||
| 106 | // all done |
|
| 107 | $log->endAction(); |
|
| 108 | return $tables->$tableName; |
|
| 109 | } |
|
| 110 | ||
| 111 | /** |
|
| 112 | * get a group from our runtime table |
|
| @@ 69-87 (lines=19) @@ | ||
| 66 | * @return BaseObject |
|
| 67 | * the created table, ready for use |
|
| 68 | */ |
|
| 69 | public function createTable($tableName) |
|
| 70 | { |
|
| 71 | // what are we doing? |
|
| 72 | $log = Log::usingLog()->startAction("create runtime table '{$tableName}'"); |
|
| 73 | ||
| 74 | // get the current runtime tables |
|
| 75 | $tables = RuntimeTable::fromRuntimeTables()->getAllTables(); |
|
| 76 | if (!isset($tables->$tableName)) { |
|
| 77 | $log->writeToLog("table does not exist; creating"); |
|
| 78 | $tables->$tableName = new BaseObject; |
|
| 79 | } |
|
| 80 | else { |
|
| 81 | $log->writeToLog("table already exists"); |
|
| 82 | } |
|
| 83 | ||
| 84 | // all done |
|
| 85 | $log->endAction(); |
|
| 86 | return $tables->$tableName; |
|
| 87 | } |
|
| 88 | ||
| 89 | /** |
|
| 90 | * remove a runtime table, even if it has content |
|