File tree Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change 33namespace Weble \LaravelEcommerce \Storage ;
44
55use Illuminate \Support \Manager ;
6+ use InvalidArgumentException ;
67
78class 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
You can’t perform that action at this time.
0 commit comments