Skip to content

Commit 82b985e

Browse files
committed
Merge branch 'release/4.0.1'
2 parents 759ae5d + eca37a9 commit 82b985e

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/Storage/StorageManager.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,34 @@
33
namespace Weble\LaravelEcommerce\Storage;
44

55
use Illuminate\Support\Manager;
6+
use InvalidArgumentException;
67

78
class StorageManager extends Manager
89
{
9-
public function store(?string $name = null): StorageInterface
10+
public function store(?string $driver = null, ?string $name = null): StorageInterface
1011
{
11-
return $this->driver($name);
12+
return $this->driver($driver, $name);
13+
}
14+
15+
public function driver($driver = null, $name = null)
16+
{
17+
$driver = $driver ?: $this->getDefaultDriver();
18+
$name = $name ?: $driver;
19+
20+
if (is_null($driver)) {
21+
throw new InvalidArgumentException(sprintf(
22+
'Unable to resolve NULL driver for [%s].', static::class
23+
));
24+
}
25+
26+
// If the given driver has not been created before, we will create the instances
27+
// here and cache it so we can return it next time very quickly. If there is
28+
// already a driver created by this name, we'll just return that instance.
29+
if (! isset($this->drivers[$driver][$name])) {
30+
$this->drivers[$driver][$name] = $this->createDriver($driver)->setInstanceName($name);
31+
}
32+
33+
return $this->drivers[$driver][$name];
1234
}
1335

1436
public function getDefaultDriver(): string

0 commit comments

Comments
 (0)