1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the ConfigCacheBundle package. |
5
|
|
|
* |
6
|
|
|
* Copyright (c) 2015-2016 Yahoo Japan Corporation |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace YahooJapan\ConfigCacheBundle\ConfigCache\Resource; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* DirectoryResource represents a resources stored in a subdirectory tree. |
18
|
|
|
*/ |
19
|
|
|
class DirectoryResource implements ResourceInterface |
20
|
|
|
{ |
21
|
|
|
protected $resource; |
22
|
|
|
protected $configuration; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Constructor. |
26
|
|
|
* |
27
|
|
|
* @param string $resource The file path to the resource |
28
|
|
|
* @param ConfigurationInterface $configuration |
29
|
|
|
*/ |
30
|
5 |
|
public function __construct($resource, ConfigurationInterface $configuration = null) |
31
|
|
|
{ |
32
|
5 |
|
$this->resource = $resource; |
33
|
5 |
|
$this->configuration = $configuration; |
34
|
5 |
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Gets configuration. |
38
|
|
|
* |
39
|
|
|
* @return ConfigurationInterface |
40
|
|
|
*/ |
41
|
4 |
|
public function getConfiguration() |
42
|
|
|
{ |
43
|
4 |
|
return $this->configuration; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Sets configuration. |
48
|
|
|
* |
49
|
|
|
* @param ConfigurationInterface $configuration |
50
|
|
|
* |
51
|
|
|
* @return DirectoryResource |
52
|
|
|
*/ |
53
|
1 |
|
public function setConfiguration(ConfigurationInterface $configuration) |
54
|
|
|
{ |
55
|
1 |
|
$this->configuration = $configuration; |
56
|
|
|
|
57
|
1 |
|
return $this; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Returns the resource tied to this Resource. |
62
|
|
|
* |
63
|
|
|
* @return mixed The resource |
64
|
|
|
*/ |
65
|
10 |
|
public function getResource() |
66
|
|
|
{ |
67
|
10 |
|
return $this->resource; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Sets the resource. |
72
|
|
|
* |
73
|
|
|
* @param string $resource |
74
|
|
|
* |
75
|
|
|
* @return DirectoryResource |
76
|
|
|
*/ |
77
|
1 |
|
public function setResource($resource) |
78
|
|
|
{ |
79
|
1 |
|
$this->resource = $resource; |
80
|
|
|
|
81
|
1 |
|
return $this; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* {@inheritdoc} |
86
|
|
|
*/ |
87
|
8 |
|
public function exists() |
88
|
|
|
{ |
89
|
8 |
|
return is_dir($this->resource); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|