Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
6cc65b53
Commit
6cc65b53
authored
9 years ago
by
Robin Appelman
Browse files
Options
Downloads
Patches
Plain Diff
add phpdoc
parent
232872e4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/private/files/storage/flysystem.php
+55
-0
55 additions, 0 deletions
lib/private/files/storage/flysystem.php
with
55 additions
and
0 deletions
lib/private/files/storage/flysystem.php
+
55
−
0
View file @
6cc65b53
...
...
@@ -15,6 +15,11 @@ use League\Flysystem\FileNotFoundException;
use
League\Flysystem\Filesystem
;
use
League\Flysystem\Plugin\GetWithMetadata
;
/**
* Generic adapter between flysystem adapters and owncloud's storage system
*
* To use: subclass and call $this->buildFlysystem with the flysystem adapter of choice
*/
abstract
class
Flysystem
extends
Common
{
/**
* @var Filesystem
...
...
@@ -26,6 +31,11 @@ abstract class Flysystem extends Common {
*/
protected
$root
=
''
;
/**
* Initialize the storage backend with a flyssytem adapter
*
* @param \League\Flysystem\AdapterInterface $adapter
*/
protected
function
buildFlySystem
(
AdapterInterface
$adapter
)
{
$this
->
flysystem
=
new
Filesystem
(
$adapter
);
$this
->
flysystem
->
addPlugin
(
new
GetWithMetadata
());
...
...
@@ -36,18 +46,30 @@ abstract class Flysystem extends Common {
return
ltrim
(
$fullPath
,
'/'
);
}
/**
* {@inheritdoc}
*/
public
function
file_get_contents
(
$path
)
{
return
$this
->
flysystem
->
read
(
$this
->
buildPath
(
$path
));
}
/**
* {@inheritdoc}
*/
public
function
file_put_contents
(
$path
,
$data
)
{
return
$this
->
flysystem
->
put
(
$this
->
buildPath
(
$path
),
$data
);
}
/**
* {@inheritdoc}
*/
public
function
file_exists
(
$path
)
{
return
$this
->
flysystem
->
has
(
$this
->
buildPath
(
$path
));
}
/**
* {@inheritdoc}
*/
public
function
unlink
(
$path
)
{
if
(
$this
->
is_dir
(
$path
))
{
return
$this
->
rmdir
(
$path
);
...
...
@@ -59,6 +81,9 @@ abstract class Flysystem extends Common {
}
}
/**
* {@inheritdoc}
*/
public
function
rename
(
$source
,
$target
)
{
if
(
$this
->
file_exists
(
$target
))
{
$this
->
unlink
(
$target
);
...
...
@@ -66,6 +91,9 @@ abstract class Flysystem extends Common {
return
$this
->
flysystem
->
rename
(
$this
->
buildPath
(
$source
),
$this
->
buildPath
(
$target
));
}
/**
* {@inheritdoc}
*/
public
function
copy
(
$source
,
$target
)
{
if
(
$this
->
file_exists
(
$target
))
{
$this
->
unlink
(
$target
);
...
...
@@ -73,6 +101,9 @@ abstract class Flysystem extends Common {
return
$this
->
flysystem
->
copy
(
$this
->
buildPath
(
$source
),
$this
->
buildPath
(
$target
));
}
/**
* {@inheritdoc}
*/
public
function
filesize
(
$path
)
{
if
(
$this
->
is_dir
(
$path
))
{
return
0
;
...
...
@@ -81,6 +112,9 @@ abstract class Flysystem extends Common {
}
}
/**
* {@inheritdoc}
*/
public
function
mkdir
(
$path
)
{
if
(
$this
->
file_exists
(
$path
))
{
return
false
;
...
...
@@ -88,10 +122,16 @@ abstract class Flysystem extends Common {
return
$this
->
flysystem
->
createDir
(
$this
->
buildPath
(
$path
));
}
/**
* {@inheritdoc}
*/
public
function
filemtime
(
$path
)
{
return
$this
->
flysystem
->
getTimestamp
(
$this
->
buildPath
(
$path
));
}
/**
* {@inheritdoc}
*/
public
function
rmdir
(
$path
)
{
try
{
return
@
$this
->
flysystem
->
deleteDir
(
$this
->
buildPath
(
$path
));
...
...
@@ -100,6 +140,9 @@ abstract class Flysystem extends Common {
}
}
/**
* {@inheritdoc}
*/
public
function
opendir
(
$path
)
{
try
{
$content
=
$this
->
flysystem
->
listContents
(
$this
->
buildPath
(
$path
));
...
...
@@ -112,6 +155,9 @@ abstract class Flysystem extends Common {
return
IteratorDirectory
::
wrap
(
$names
);
}
/**
* {@inheritdoc}
*/
public
function
fopen
(
$path
,
$mode
)
{
$fullPath
=
$this
->
buildPath
(
$path
);
$useExisting
=
true
;
...
...
@@ -157,6 +203,9 @@ abstract class Flysystem extends Common {
return
false
;
}
/**
* {@inheritdoc}
*/
public
function
touch
(
$path
,
$mtime
=
null
)
{
if
(
$this
->
file_exists
(
$path
))
{
return
false
;
...
...
@@ -166,6 +215,9 @@ abstract class Flysystem extends Common {
}
}
/**
* {@inheritdoc}
*/
public
function
stat
(
$path
)
{
$info
=
$this
->
flysystem
->
getWithMetadata
(
$this
->
buildPath
(
$path
),
[
'timestamp'
,
'size'
]);
return
[
...
...
@@ -174,6 +226,9 @@ abstract class Flysystem extends Common {
];
}
/**
* {@inheritdoc}
*/
public
function
filetype
(
$path
)
{
if
(
$path
===
''
or
$path
===
'/'
or
$path
===
'.'
)
{
return
'dir'
;
...
...
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
register
or
sign in
to comment