Final Class Yiisoft\Rbac\Cycle\ItemTreeTraversal\ItemTreeTraversalFactory
| Inheritance | Yiisoft\ |
|---|
A factory for creating item tree traversal strategy depending on used RDBMS.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| getItemTreeTraversal() | Creates item tree traversal strategy depending on used RDBMS. | Yiisoft\ |
Method Details
Creates item tree traversal strategy depending on used RDBMS.
| public static Yiisoft\ | ||
| $database | \ |
Cycle database instance. |
| $tableName | string |
A name of the table for storing RBAC items. |
| $childrenTableName | string |
A name of the table for storing relations between RBAC items. |
| $namesSeparator | string |
Separator used for joining item names. |
| return | Yiisoft\ |
Item tree traversal strategy. |
|---|---|---|
| throws | RuntimeException |
When a database was configured with an unknown driver, either because it is not supported by Cycle out of the box or newly added by Cycle and not supported / tested yet in this package. |
public static function getItemTreeTraversal(
DatabaseInterface $database,
string $tableName,
string $childrenTableName,
string $namesSeparator,
): ItemTreeTraversalInterface {
$arguments = [$database, $tableName, $childrenTableName, $namesSeparator];
$driverType = $database->getDriver()->getType();
// default - ignored due to the complexity of testing and preventing splitting of database argument.
// @codeCoverageIgnoreStart
return match ($driverType) {
'SQLite' => new SqliteCteItemTreeTraversal(...$arguments),
'MySQL' => self::getMysqlItemTreeTraversal($database, $tableName, $childrenTableName, $namesSeparator),
'Postgres' => new PostgresCteItemTreeTraversal(...$arguments),
'SQLServer' => new SqlServerCteItemTreeTraversal(...$arguments),
default => throw new RuntimeException("$driverType database driver is not supported."),
};
// @codeCoverageIgnoreEnd
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.