trait PathTrait in Tome 8
Contains methods useful for working with paths.
@internal
Hierarchy
- trait \Drupal\tome_base\PathTrait
8 files declare their use of PathTrait
- CleanFilesCommand.php in modules/
tome_sync/ src/ Commands/ CleanFilesCommand.php - Exporter.php in modules/
tome_sync/ src/ Exporter.php - FileSync.php in modules/
tome_sync/ src/ FileSync.php - LanguagePathSubscriber.php in modules/
tome_static/ src/ EventSubscriber/ LanguagePathSubscriber.php - PathTraitTest.php in modules/
tome_base/ tests/ src/ Unit/ PathTraitTest.php
File
- modules/
tome_base/ src/ PathTrait.php, line 10
Namespace
Drupal\tome_baseView source
trait PathTrait {
/**
* Joins multiple paths.
*
* Original credit to Riccardo Galli.
*
* @see https://stackoverflow.com/a/15575293
*
* @return string
* The joined path.
*/
protected function joinPaths() {
$paths = [];
foreach (func_get_args() as $arg) {
if ($arg !== '') {
$paths[] = $arg;
}
}
return rtrim(preg_replace('#(?<!:)/+#', '/', implode('/', $paths)), '/');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PathTrait:: |
protected | function | Joins multiple paths. |