1: <?php
2:
3: namespace PHPixie\Filesystem\Locators;
4:
5: class Builder
6: {
7: protected $locators;
8: protected $root;
9: protected $locatorRegistry;
10:
11: public function __construct($locators, $root, $locatorRegistry = null)
12: {
13: $this->locators = $locators;
14: $this->root = $root;
15: $this->locatorRegistry = $locatorRegistry;
16: }
17:
18: protected function directory($configData)
19: {
20: return $this->locators->directory($this->root, $configData);
21: }
22:
23: protected function group($configData)
24: {
25: return $this->locators->group($this, $configData);
26: }
27:
28: protected function prefix($configData)
29: {
30: return $this->locators->prefix($this, $configData);
31: }
32:
33: protected function mount($configData)
34: {
35: if ($this->locatorRegistry === null) {
36: throw new \PHPixie\Filesystem\Exception("Locator registry was not set");
37: }
38:
39: return $this->locators->mount($this->locatorRegistry, $configData);
40: }
41:
42: public function buildFromConfig($configData) {
43: $type = $configData->get('type', 'directory');
44: return $this->$type($configData);
45: }
46: }