-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'prefix' and 'url' configuration options
- Loading branch information
Showing
3 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Mzur\Filesystem; | ||
|
||
use OpenStack\ObjectStore\v1\Models\Container; | ||
use Nimbusoft\Flysystem\OpenStack\SwiftAdapter as BaseAdapter; | ||
|
||
class SwiftAdapter extends BaseAdapter | ||
{ | ||
/** | ||
* Optional base URL to use for this adapter. | ||
* | ||
* @var string | ||
*/ | ||
protected $url; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param Container $container | ||
* @param string $prefix | ||
*/ | ||
public function __construct(Container $container, $prefix = null, $url = null) | ||
{ | ||
parent::__construct($container, $prefix); | ||
$this->url = rtrim($url, '/'); | ||
} | ||
|
||
/** | ||
* Get the URL for the file at the given path. | ||
* | ||
* @param string $path | ||
* @return string | ||
*/ | ||
public function getUrl($path) | ||
{ | ||
if ($this->url) { | ||
return "{$this->url}/{$path}"; | ||
} | ||
|
||
return $this->container->getObject($path)->getPublicUri(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters