1: <?php
2:
3: namespace PHPixie\BundleFramework;
4:
5: use PHPixie\Filesystem\Root;
6:
7: /**
8: * Assets registry
9: */
10: class Assets extends \PHPixie\Framework\Assets
11: {
12: /**
13: * @var string
14: */
15: protected $rootDirectory;
16:
17: /**
18: * Constructor
19: * @param Components $components
20: * @param string $rootDirectory
21: */
22: public function __construct($components, $rootDirectory)
23: {
24: $this->rootDirectory = $rootDirectory;
25:
26: parent::__construct($components);
27: }
28:
29: /**
30: * Project folder
31: * @return Root
32: */
33: public function root()
34: {
35: return $this->instance('root');
36: }
37:
38: /**
39: * Assets folder
40: * @return Root
41: */
42: public function assetsRoot()
43: {
44: return $this->instance('assetsRoot');
45: }
46:
47: /**
48: * Web folder
49: * @return Root
50: */
51: public function webRoot()
52: {
53: return $this->instance('webRoot');
54: }
55:
56: /**
57: * Configuration storage
58: * @return \PHPixie\Config\Storages\Type\Directory
59: */
60: public function configStorage()
61: {
62: return $this->instance('configStorage');
63: }
64:
65: /**
66: * @return Root
67: */
68: protected function buildRoot()
69: {
70: return $this->buildFilesystemRoot(
71: $this->rootDirectory
72: );
73: }
74:
75: /**
76: * @return Root
77: */
78: protected function buildAssetsRoot()
79: {
80: return $this->buildFilesystemRoot(
81: $this->root()->path('assets')
82: );
83: }
84:
85: /**
86: * @return Root
87: */
88: protected function buildWebRoot()
89: {
90: return $this->buildFilesystemRoot(
91: $this->root()->path('web')
92: );
93: }
94:
95: /**
96: * @return \PHPixie\Config\Storages\Type\Directory
97: */
98: protected function buildConfigStorage()
99: {
100: $config = $this->components->config();
101:
102: return $config->directory(
103: $this->assetsRoot()->path(),
104: 'config'
105: );
106: }
107: }