1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2022 |
6
|
|
|
* @package Base |
7
|
|
|
* @subpackage Filesystem |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\Base\Filesystem\Manager; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Laravel file system manager |
16
|
|
|
* |
17
|
|
|
* @package Base |
18
|
|
|
* @subpackage Filesystem |
19
|
|
|
*/ |
20
|
|
|
class Laravel extends Standard implements Iface |
21
|
|
|
{ |
22
|
|
|
private $fsm; |
23
|
|
|
private $objects = []; |
24
|
|
|
private $tempdir; |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Initializes the object |
29
|
|
|
* |
30
|
|
|
* @param \Illuminate\Filesystem\FilesystemManager $fsm Laravel file system manager object |
31
|
|
|
* @param array $config Filesystem resource configuration |
32
|
|
|
* @param string $tempdir Directory for storing temporary files |
33
|
|
|
*/ |
34
|
|
|
public function __construct( \Illuminate\Filesystem\FilesystemManager $fsm, array $config, $tempdir ) |
35
|
|
|
{ |
36
|
|
|
parent::__construct( $config ); |
37
|
|
|
|
38
|
|
|
$this->fsm = $fsm; |
39
|
|
|
$this->tempdir = $tempdir; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Cleans up the object |
45
|
|
|
*/ |
46
|
|
|
public function __destruct() |
47
|
|
|
{ |
48
|
|
|
foreach( $this->objects as $key => $object ) { |
49
|
|
|
unset( $this->objects[$key] ); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Clean up the objects inside |
56
|
|
|
*/ |
57
|
|
|
public function __sleep() |
58
|
|
|
{ |
59
|
|
|
$this->__destruct(); |
60
|
|
|
|
61
|
|
|
$this->objects = []; |
62
|
|
|
|
63
|
|
|
return get_object_vars( $this ); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Returns the file system for the given name |
69
|
|
|
* |
70
|
|
|
* @param string $name Key for the file system |
71
|
|
|
* @return \Aimeos\Base\Filesystem\Iface File system object |
72
|
|
|
* @throws \Aimeos\Base\Filesystem\Exception If an no configuration for that name is found |
73
|
|
|
*/ |
74
|
|
|
public function get( string $name ) : \Aimeos\Base\Filesystem\Iface |
75
|
|
|
{ |
76
|
|
|
$key = $this->getConfig( $name ); |
77
|
|
|
|
78
|
|
|
if( is_string( $key ) ) |
79
|
|
|
{ |
80
|
|
|
if( !isset( $this->objects[$key] ) ) { |
81
|
|
|
$this->objects[$key] = new \Aimeos\Base\Filesystem\Laravel( $this->fsm->disk( $key ), $this->tempdir ); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
return $this->objects[$key]; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
return parent::get( $name ); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|