Skip to content

Commit

Permalink
Proxy command: skip tables luyadev#142
Browse files Browse the repository at this point in the history
  • Loading branch information
boehsermoe committed May 30, 2018
1 parent de9f569 commit ef2bfc8
Showing 1 changed file with 37 additions and 15 deletions.
52 changes: 37 additions & 15 deletions src/proxy/ClientBuild.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,41 +71,63 @@ public function init()
}

private $_buildConfig;

public function setBuildConfig(array $config)
{
$this->_buildConfig = $config;

foreach ($config['tables'] as $tableName => $tableConfig) {
if (!empty($this->optionTable)) {
$skip = true;

foreach ($this->optionTable as $useName) {
if ($useName == $tableName || StringHelper::startsWithWildcard($tableName, $useName)) {
$skip = false;
}
}


$skip = $this->skipTable($tableName);
if ($skip) {
continue;
}
}

$schema = Yii::$app->db->getTableSchema($tableName);

if ($schema !== null) {
$this->_tables[$tableName] = new ClientTable($this, $tableConfig);
}
}
}


/**
* @param $tableName
* @return bool
*
* @since 1.2.1
*/
private function skipTable($tableName): bool
{
$skip = true;

foreach ($this->optionTable as $useName) {

$exlude = false;
if (substr($useName, 0, 1) == "!") {
$exlude = true;
$skip = false;

$useName = substr($useName, 1);
}

if ($useName == $tableName || StringHelper::startsWithWildcard($tableName, $useName)) {
return $exlude;
}
}

return $skip;
}

public function getStorageFilesCount()
{
return $this->_buildConfig['storageFilesCount'];
}

private $_tables = [];

public function getTables()
{
return $this->_tables;
Expand Down

0 comments on commit ef2bfc8

Please sign in to comment.