| 1 |
<?php |
| 2 |
namespace Depicter\Services; |
| 3 |
|
| 4 |
|
| 5 |
use Averta\WordPress\File\FileSystem; |
| 6 |
use Averta\WordPress\File\UploadsDirectory; |
| 7 |
|
| 8 |
class StorageService |
| 9 |
{ |
| 10 |
const UPLOADS_FOLDER_NAME = 'depicter'; |
| 11 |
|
| 12 |
/** |
| 13 |
* @var FileSystem |
| 14 |
*/ |
| 15 |
private $filesystem; |
| 16 |
|
| 17 |
/** |
| 18 |
* @var UploadsDirectory |
| 19 |
*/ |
| 20 |
private $uploads; |
| 21 |
|
| 22 |
|
| 23 |
public function __construct(){ |
| 24 |
$this->filesystem = new FileSystem(); |
| 25 |
$this->uploads = new UploadsDirectory(); |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* Access to filesystem module |
| 30 |
* |
| 31 |
* @return FileSystem |
| 32 |
*/ |
| 33 |
public function filesystem(){ |
| 34 |
return $this->filesystem; |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* Access to uploads directory info |
| 39 |
* |
| 40 |
* @return UploadsDirectory |
| 41 |
*/ |
| 42 |
public function uploads(){ |
| 43 |
return $this->uploads; |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Retrieves the special plugin's folder in uploads directory |
| 48 |
* |
| 49 |
* @return string |
| 50 |
*/ |
| 51 |
public function getPluginUploadsDirectory(){ |
| 52 |
return $this->uploads()->getBaseDirectory() . '/'. self::UPLOADS_FOLDER_NAME; |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Retrieves the special plugin's folder in uploads directory for CSS files |
| 57 |
* |
| 58 |
* @return string |
| 59 |
*/ |
| 60 |
public function getCssUploadsDirectory(){ |
| 61 |
return $this->uploads()->getBaseDirectory() . '/'. self::UPLOADS_FOLDER_NAME . '/css'; |
| 62 |
} |
| 63 |
|
| 64 |
/** |
| 65 |
* Retrieves the url of special plugin's folder in uploads directory for CSS files |
| 66 |
* |
| 67 |
* @return string |
| 68 |
*/ |
| 69 |
public function getCssUploadsUrl(){ |
| 70 |
return $this->uploads()->getBaseUrl() . '/'. self::UPLOADS_FOLDER_NAME . '/css'; |
| 71 |
} |
| 72 |
|
| 73 |
} |
| 74 |
|