We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I sometimes write hacky code like this:
$tableName = 'Product'; $stage = Versioned::get_stage(); if ($stage === 'Live') { $tableName .= '_Live'; }
The "proper" way to write this would be:
$sng = DataObject::singleton(Product::class); $schema = $sng->getSchema(); $tableName = $schema->tableName(Product::class); $tableName = $sng->stageTable($tableName, Versioned::get_stage());
It would be nice if I could write:
$tableName = Versioned::get_stage_table(Product::class);
This means that we should take stageTable from Versioned and add a static function: https://github.com/silverstripe/silverstripe-versioned/blob/2/src/Versioned.php#L2125-L2131
public function stageTable(?string $table = '', ?string $stage = '') { if(! $tableName) { $schema = $sng->getSchema(); $table = $schema->tableName(get_class($this->getOwner())); } if($this->hasStages()) { if(! $stage) { $stage = self::get_stage(); } if ($this->hasStages() && $stage === static::LIVE) { return "{$table}_{$stage}"; } } return $table; } public static function get_stage_table_from_class_name(string $className, ?string $stage = '') { $obj = Injector::inst()->get($className); $tableName = $obj->getSchema()->tableName($className); return $obj->stageTable($tableName, $stage); }
No response
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Description
I sometimes write hacky code like this:
The "proper" way to write this would be:
It would be nice if I could write:
This means that we should take stageTable from Versioned and add a static function:
https://github.com/silverstripe/silverstripe-versioned/blob/2/src/Versioned.php#L2125-L2131
Additional context or points of discussion
No response
Validations
The text was updated successfully, but these errors were encountered: