Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
flysystem
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
flysystem
Commits
9d09a8d2
Commit
9d09a8d2
authored
Jul 20, 2016
by
Chris Leppanen
Committed by
Chris Leppanen
Jul 20, 2016
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2728865
by twistor: Allow custom names for stream wrappers
parent
4cafd9aa
Branches
Branches containing commit
Tags
8.x-1.0-alpha4
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.md
+3
-0
3 additions, 0 deletions
README.md
src/FlysystemBridge.php
+10
-2
10 additions, 2 deletions
src/FlysystemBridge.php
src/FlysystemFactory.php
+15
-13
15 additions, 13 deletions
src/FlysystemFactory.php
tests/src/Unit/FlysystemBridgeTest.php
+2
-0
2 additions, 0 deletions
tests/src/Unit/FlysystemBridgeTest.php
with
30 additions
and
15 deletions
README.md
+
3
−
0
View file @
9d09a8d2
...
...
@@ -73,6 +73,9 @@ $schemes = [
// Optional settings that apply to all adapters.
'name'
=>
'Custom stream wrapper name'
,
// Defaults to Flysystem: scheme.
'description'
=>
'Custom description'
,
// Defaults to Flysystem: scheme.
'cache'
=>
TRUE
,
// Cache filesystem metadata. Not necessary for
// the local driver.
...
...
This diff is collapsed.
Click to expand it.
src/FlysystemBridge.php
+
10
−
2
View file @
9d09a8d2
...
...
@@ -25,14 +25,22 @@ class FlysystemBridge extends FlysystemStreamWrapper implements StreamWrapperInt
* {@inheritdoc}
*/
public
function
getName
()
{
return
$this
->
t
(
'Flysystem: @scheme'
,
[
'@scheme'
=>
$this
->
getProtocol
()]);
$scheme
=
$this
->
getProtocol
();
$name
=
(
string
)
$this
->
getFactory
()
->
getSettings
(
$scheme
)[
'name'
];
$default
=
$this
->
t
(
'Flysystem: @scheme'
,
[
'@scheme'
=>
$scheme
]);
return
$name
!==
''
?
$this
->
t
(
$name
)
:
$default
;
}
/**
* {@inheritdoc}
*/
public
function
getDescription
()
{
return
$this
->
t
(
'Flysystem: @scheme'
,
[
'@scheme'
=>
$this
->
getProtocol
()]);
$scheme
=
$this
->
getProtocol
();
$description
=
(
string
)
$this
->
getFactory
()
->
getSettings
(
$scheme
)[
'description'
];
$default
=
$this
->
t
(
'Flysystem: @scheme'
,
[
'@scheme'
=>
$scheme
]);
return
$description
!==
''
?
$this
->
t
(
$description
)
:
$default
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
src/FlysystemFactory.php
+
15
−
13
View file @
9d09a8d2
...
...
@@ -29,6 +29,8 @@ class FlysystemFactory {
'config'
=>
[],
'replicate'
=>
FALSE
,
'cache'
=>
FALSE
,
'name'
=>
''
,
'description'
=>
''
,
];
/**
...
...
@@ -148,6 +150,19 @@ class FlysystemFactory {
return
array_keys
(
$this
->
settings
);
}
/**
* Finds the settings for a given scheme.
*
* @param string $scheme
* The scheme.
*
* @return array
* The settings array from settings.php.
*/
public
function
getSettings
(
$scheme
)
{
return
isset
(
$this
->
settings
[
$scheme
])
?
$this
->
settings
[
$scheme
]
:
$this
->
defaults
;
}
/**
* Calls FlysystemPluginInterface::ensure() on each plugin.
*
...
...
@@ -199,17 +214,4 @@ class FlysystemFactory {
return
$adapter
;
}
/**
* Finds the settings for a given scheme.
*
* @param string $scheme
* The scheme.
*
* @return array
* The settings array from settings.php.
*/
protected
function
getSettings
(
$scheme
)
{
return
isset
(
$this
->
settings
[
$scheme
])
?
$this
->
settings
[
$scheme
]
:
$this
->
defaults
;
}
}
This diff is collapsed.
Click to expand it.
tests/src/Unit/FlysystemBridgeTest.php
+
2
−
0
View file @
9d09a8d2
...
...
@@ -43,6 +43,8 @@ class FlysystemBridgeTest extends UnitTestCase {
$factory
->
getFilesystem
(
'testscheme'
)
->
willReturn
(
$this
->
filesystem
);
$factory
->
getSettings
(
'testscheme'
)
->
willReturn
([
'name'
=>
''
,
'description'
=>
''
]);
$container
=
new
ContainerBuilder
();
$container
->
set
(
'flysystem_factory'
,
$factory
->
reveal
());
\Drupal
::
setContainer
(
$container
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment