1 | <?php |
||
22 | class TenantAwarePathBuilder implements TenantAwarePathBuilderInterface |
||
23 | { |
||
24 | /** |
||
25 | * @var TenantContextInterface |
||
26 | */ |
||
27 | protected $tenantContext; |
||
28 | |||
29 | /** |
||
30 | * @var string |
||
31 | */ |
||
32 | protected $rootPath; |
||
33 | |||
34 | /** |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $latestRootPath; |
||
38 | |||
39 | /** |
||
40 | * @var string |
||
41 | */ |
||
42 | protected $defaultRootPath; |
||
43 | |||
44 | /** |
||
45 | * Construct. |
||
46 | * |
||
47 | * @param TenantContextInterface $tenantContext Tenant context |
||
48 | * @param string $rootPath PHPCR root path (e.g. /swp) |
||
49 | */ |
||
50 | public function __construct(TenantContextInterface $tenantContext, $rootPath) |
||
51 | { |
||
52 | $this->tenantContext = $tenantContext; |
||
53 | $this->rootPath = $rootPath; |
||
54 | $this->defaultRootPath = $rootPath; |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * {@inheritdoc} |
||
59 | */ |
||
60 | public function build($data, $context = null) |
||
61 | { |
||
62 | return $this->absolutize($data, $context); |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Absolutize path or paths based on current context when provided. |
||
67 | * |
||
68 | * @param string|array $data Path or array of paths |
||
69 | * @param string $context Path absolute context |
||
70 | * |
||
71 | * @return string|array Tenant aware paths |
||
72 | */ |
||
73 | protected function absolutize($data, $context = null) |
||
87 | |||
88 | /** |
||
89 | * Makes PHPCR tree root path to be tenant aware. |
||
90 | * |
||
91 | * When tenant is not available in tenant context it will resolve |
||
92 | * the tenant from current request. |
||
93 | */ |
||
94 | protected function makePathTenantAware() |
||
104 | |||
105 | private function absolutizePath($path, $context = null) |
||
106 | { |
||
117 | } |
||
118 |