1: <?php
2:
3: namespace PHPixie\BundleFramework\Configuration;
4:
5: use PHPixie\Filesystem\Locators\Locator;
6:
7: 8: 9:
10: class FilesystemLocator implements \PHPixie\Filesystem\Locators\Locator
11: {
12: 13: 14:
15: protected $bundleLocators;
16:
17: 18: 19:
20: protected $overridesLocator;
21:
22: 23: 24: 25: 26:
27: public function __construct($bundleLocators, $overridesLocator = null)
28: {
29: $this->bundleLocators = $bundleLocators;
30: $this->overridesLocator = $overridesLocator;
31: }
32:
33: 34: 35:
36: public function locate($name, $isDirectory = false)
37: {
38: if($this->overridesLocator !== null) {
39: $path = $this->overridesLocator->locate($name, $isDirectory);
40: if($path !== null) {
41: return $path;
42: }
43: }
44:
45: $split = explode(':', $name, 2);
46: if(count($split) !== 2 ) {
47: return null;
48: }
49:
50: list($locatorName, $name) = $split;
51:
52: $locator = $this->getLocator($locatorName);
53:
54: if($locator === null) {
55: return null;
56: }
57:
58: return $locator->locate($name, $isDirectory);
59: }
60:
61: 62: 63: 64:
65: protected function getLocator($name)
66: {
67: return $this->getBundleLocator($name);
68: }
69:
70: 71: 72: 73:
74: protected function getBundleLocator($name)
75: {
76: return $this->bundleLocators->bundleLocator($name, false);
77: }
78: }