1 | <?php |
||
24 | class TenantAwarePathBuilder implements TenantAwarePathBuilderInterface |
||
25 | { |
||
26 | /** |
||
27 | * @var TenantResolverInterface |
||
28 | */ |
||
29 | protected $tenantResolver; |
||
30 | |||
31 | /** |
||
32 | * @var TenantContextInterface |
||
33 | */ |
||
34 | protected $tenantContext; |
||
35 | |||
36 | /** |
||
37 | * @var string |
||
38 | */ |
||
39 | protected $rootPath; |
||
40 | |||
41 | /** |
||
42 | * @var RequestStack |
||
43 | */ |
||
44 | protected $requestStack; |
||
45 | |||
46 | /** |
||
47 | * @var string |
||
48 | */ |
||
49 | protected $latestRootPath; |
||
50 | |||
51 | /** |
||
52 | * @var string |
||
53 | */ |
||
54 | protected $defaultRootPath; |
||
55 | |||
56 | /** |
||
57 | * Construct. |
||
58 | * |
||
59 | * @param TenantResolverInterface $tenantResolver Tenant resolver |
||
60 | * @param TenantContextInterface $tenantContext Tenant context |
||
61 | * @param string $rootPath PHPCR root path (e.g. /swp) |
||
62 | */ |
||
63 | public function __construct(TenantResolverInterface $tenantResolver, TenantContextInterface $tenantContext, $rootPath) |
||
70 | |||
71 | /** |
||
72 | * {@inheritdoc} |
||
73 | */ |
||
74 | public function build($data, $context = null) |
||
78 | |||
79 | /** |
||
80 | * Absolutize path or paths based on current context when provided. |
||
81 | * |
||
82 | * @param string|array $data Path or array of paths |
||
83 | * @param string $context Path absolute context |
||
84 | * |
||
85 | * @return string|array Tenant aware paths |
||
86 | */ |
||
87 | protected function absolutize($data, $context = null) |
||
101 | |||
102 | /** |
||
103 | * Makes PHPCR tree root path to be tenant aware. |
||
104 | * |
||
105 | * When tenant is not available in tenant context it will resolve |
||
106 | * the tenant from current request. |
||
107 | */ |
||
108 | protected function makePathTenantAware() |
||
127 | |||
128 | private function absolutizePath($path, $context = null) |
||
140 | |||
141 | /** |
||
142 | * Sets the RequestStack. |
||
143 | * |
||
144 | * @param RequestStack $requestStack |
||
145 | */ |
||
146 | public function setRequestStack(RequestStack $requestStack) |
||
150 | |||
151 | /** |
||
152 | * Gets the RequestStack object. |
||
153 | * |
||
154 | * @return RequestStack |
||
155 | */ |
||
156 | public function getRequestStack() |
||
160 | } |
||
161 |