Skip to content

Commit

Permalink
Make the depth and length passable via config
Browse files Browse the repository at this point in the history
  • Loading branch information
weotch committed Jan 16, 2018
1 parent 64905ec commit b797dbf
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
10 changes: 10 additions & 0 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,14 @@
* Whether to delete files when a model is soft deleted.
*/
'keep_files_when_soft_deleted' => false,

/**
* How deep to nest files within subdirectories
*/
'depth' => 2,

/**
* How many folders will be created in each depth
*/
'length' => 16,
];
7 changes: 6 additions & 1 deletion src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ public function register() {

// Instantiate storage class
$this->app->singleton('upchuck.storage', function($app) {
return new Storage($app['upchuck.manager'], $app['upchuck']);
return new Storage(
$app['upchuck.manager'],
$app['upchuck'],
$app['config']->get('upchuck.depth'),
$app['config']->get('upchuck.length')
);
});

}
Expand Down
14 changes: 8 additions & 6 deletions src/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,34 @@ class Storage {
*
* @var integer
*/
private $depth = 2;
protected $depth;

/**
* How many folders are in each depth
*
* @var integer
*/
private $length = 16;
protected $length;

/**
* @var Bkwld\Upchuck\Helpers
*/
private $helpers;
protected $helpers;

/**
* @var League\Flysystem\MountManager
*/
private $manager;

protected $manager;

/**
* Dependency injection
*/
public function __construct(MountManager $manager, Helpers $helpers) {
public function __construct(MountManager $manager, Helpers $helpers,
$depth, $length) {
$this->manager = $manager;
$this->helpers = $helpers;
$this->depth = $depth;
$this->length = $length;
}

/**
Expand Down

0 comments on commit b797dbf

Please sign in to comment.