| <?php |
|
|
| |
| |
| |
| |
| |
| |
|
|
| namespace Piwik\Plugin; |
|
|
| use Piwik\Container\StaticContainer; |
| use Piwik\DataAccess\LogTableTemporary; |
| use Piwik\Piwik; |
| use Piwik\Tracker\LogTable; |
|
|
| class LogTablesProvider |
| { |
| |
| |
| |
| private $pluginManager; |
|
|
| |
| |
| |
| private $tablesCache; |
|
|
| |
| |
| |
| private $tempTable; |
|
|
| public function __construct(Manager $pluginManager) |
| { |
| $this->pluginManager = $pluginManager; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| public function getLogTable($tableNameWithoutPrefix) |
| { |
| if ($this->tempTable && $this->tempTable->getName() === $tableNameWithoutPrefix) { |
| return $this->tempTable; |
| } |
| foreach ($this->getAllLogTables() as $table) { |
| if ($table->getName() === $tableNameWithoutPrefix) { |
| return $table; |
| } |
| } |
|
|
| return null; |
| } |
|
|
| |
| |
| |
| public function setTempTable($table) |
| { |
| $this->tempTable = $table; |
| } |
|
|
| public function clearCache() |
| { |
| $this->tablesCache = null; |
| } |
|
|
| |
| |
| |
| |
| public function getAllLogTablesWithTemporary() |
| { |
| $tables = $this->getAllLogTables(); |
| if ($this->tempTable) { |
| $tables[] = $this->tempTable; |
| } |
| return $tables; |
| } |
|
|
| |
| |
| |
| |
| |
| public function getAllLogTables() |
| { |
| if (!isset($this->tablesCache)) { |
| $tables = $this->pluginManager->findMultipleComponents('Tracker', 'Piwik\\Tracker\\LogTable'); |
|
|
| $logTables = array(); |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| Piwik::postEvent('LogTables.addLogTables', array(&$logTables)); |
|
|
| foreach ($tables as $table) { |
| $logTables[] = StaticContainer::get($table); |
| } |
|
|
| $this->tablesCache = $logTables; |
| } |
|
|
| return $this->tablesCache; |
| } |
| } |
|
|